Using route command

Assume you want to route the traffic for network 192.168.5.0 
  through interface  eth1 serving  192.168.1.0 network

Verify current routing info :

[root@gract1 Desktop]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 08:00:27:29:54:EF  
          inet addr:192.168.1.111  Bcast:192.168.1.255  Mask:255.255.255.0

[root@gract1 ~]#  netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth2
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1
192.168.2.0     0.0.0.0         255.255.255.0   U         0 0          0 eth2
192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 eth3
[root@gract1 ~]# ping 192.168.5.50
PING 192.168.5.50 (192.168.5.50) 56(84) bytes of data.
From 192.168.1.111 icmp_seq=2 Destination Host Unreachable
From 192.168.1.111 icmp_seq=3 Destination Host Unreachable
From 192.168.1.111 icmp_seq=4 Destination Host Unreachable

Add routing info :
[root@gract1 ~]# ip route add 192.168.5.0/24 dev eth1
[root@gract1 ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth2
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1
192.168.2.0     0.0.0.0         255.255.255.0   U         0 0          0 eth2
192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 eth3
192.168.5.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1

Verify that ping and nslookup are working 
[root@gract1 ~]# ping  192.168.5.50
PING 192.168.5.50 (192.168.5.50) 56(84) bytes of data.
64 bytes from 192.168.5.50: icmp_seq=1 ttl=64 time=0.929 ms
64 bytes from 192.168.5.50: icmp_seq=2 ttl=64 time=0.264 ms
--- 192.168.5.50 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1004ms
rtt min/avg/max/mdev = 0.264/0.596/0.929/0.333 ms

[root@gract1 ~]# nslookup ns1
Server:        192.168.1.50
Address:    192.168.1.50#53
Name:    ns1.example.com
Address: 192.168.5.50

To delete the above created route run :
[root@gract1 ~]#  ip route del 192.168.5.0/24 dev eth1

JAVA EE7 and JDBC integration in a RAC env

Learning the SCAN address used in our JDBC DataSource URL

  • Connect to any of your RAC nodes and execute the following instructions
Connect to any of your  RAC nodes:
[oracle@grac41 ~]$ srvctl config scan
SCAN name: grac4-scan.grid4.example.com, Network: 1/192.168.1.0/255.255.255.0/eth1
-->  grac4-scan.grid4.example.com is the host name used in our JDBC URL

Query the local listener to get Portnumber and Service Name 
[oracle@grac41 ~]$ lsnrctl status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
..
Service "grac4" has 1 instance(s).
  Instance "grac41", status READY, has 1 handler(s) for this service...
Service "grac41" has 1 instance(s).
  Instance "grac41", status READY, has 1 handler(s) for this service...

Verify with sqlplus
[oracle@grac41 ~]$ sqlplus scott/tiger@grac4-scan.grid4.example.com:1521/grac4 @v1
SQL> select host_name,instance_name from v$instance;
HOST_NAME               INSTANCE_NAME
------------------------------ ----------------
grac41.example.com           grac41

Test your JDBC connectivity ( use the JDK in $ORACLE_HOME/jdk/bin ) 
[oracle@grac41 JDBC]$  javac version.java  ( Download  : version.java )  

[oracle@grac41 JDBC]$ java version jdbc:oracle:thin:@grac4-scan.grid4.example.com:1521/grac4 scott tiger
Locale: United States English
Driver Name             : Oracle JDBC driver
Driver Version          : 11.2.0.3.0
Driver Major Version    : 11
Driver Minor Version    : 2
Database Product Name   : Oracle
Database Product Version: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
JVM version             : 1.7.0_51
JVM vendor              : Oracle Corporation
JDK version             : 24.45-b08
CLASSPATH               :     /u01/app/oracle/product/11204/racdb/jdbc/lib/ojdbc6.jar:/home/oracle/RAC/JDBC/ucp.jar:.
LD_LIBRARY_PATH         :     /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

 ..connected 
Hello JDBC: 03-DEC-14 from database GRAC4
[oracle@wls1 JDBC]$ ls /u01/app/oracle/product/fmw12cr3/oracle_common/modules/oracle.jdbc_12.1.0/
aqapi.jar  ojdbc6dms.jar  ojdbc6_g.jar  ojdbc6.jar  ojdbc7dms.jar  ojdbc7_g.jar  ojdbc7.jar
[oracle@wls1 JDBC]$  export CLASSPATH=.:/u01/app/oracle/product/fmw12cr3/oracle_common/modules/oracle.jdbc_12.1.0/ojdbc6.jar
[oracle@wls1 JDBC]$ javac version.java
[oracle@wls1 JDBC]$  java version jdbc:oracle:thin:@grac4-scan.grid4.example.com:1521/grac4 scotyyt tiger
Locale: United States English
Driver Name             : Oracle JDBC driver
Driver Version          : 12.1.0.2.0
Driver Major Version    : 12
Driver Minor Version    : 1
Database Product Name   : Oracle
Database Product Version: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
JVM version             : 1.7.0_71
JVM vendor              : Oracle Corporation
JDK version             : 24.71-b01
CLASSPATH               :     .:/u01/app/oracle/product/fmw12cr3/oracle_common/modules/oracle.jdbc_12.1.0/ojdbc6.jar
LD_LIBRARY_PATH         :     /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

 ..connected 

Hello JDBC: 03-DEC-14 from database GRAC4

Setup JDBC Connection Pool/Resource in our Glassfish Server

Connect to Glassfish Admin console : http://localhost:4848
 --> JDBC --> JDBC Connect pools -> PoolName : Grac4pool -> Resource Type javx.sql.XADataSource 

Copy ojdbc6.jar to the glassfish Webserver: 
[root@wls1 Desktop]#  cp /u01/app/oracle/product/fmw12cr3/oracle_common/modules/oracle.jdbc_12.1.0/ojdbc6.jar  /usr/local/glassfish-4.1/glassfish/lib
[root@wls1 Desktop]# chmod 644  /usr/local/glassfish-4.1/glassfish/lib/ojdbc6.jar
--> restart glassfish

XA Settings: 
Resource Type       :  javax.sql.XADataSource ( allows 2PC protocoll
Datasource Classname:  oracle.jdbc.xa.client.OracleXADataSource

Add. Properties:
portNumber    : 1521
databaseName  : grac4
datasourceName: grac4ds
serverName    : grac4-scan.grid4.example.com  ( SCAN name )
user          : scott
password      : tiger 
url           : jdbc:oracle:thin:@grac4-scan.grid4.example.com:1521/grac4 

Now press ping button ( should get Ping succeeded message )

--> Either modify the default DataSource create as new DataSource or init the DS with pur java code 

- Modify DEFAULT Datasource to point to our grac4pool
  Service -> JDBC -> JDBC Resources -> jdbc/__default -> RC properties -> PoolName : Grac4pool 

  Modify your JAVA code  and change the default DS with annotations : 
     @Resource(name="jdbc/__default") 
   private DataSource ds;
  or 
    @Resource(name="java.comp/DefaultDataSource")
   private DataSource ds;

- Create an own JDBC Resource named jdbc/rac
     @Resource(name="jdbc/rac")
   private DataSource ds;
or
     @Resource(name=java.comp/rac")
   private DataSource ds;

- Manually  initialize the DataSource with pure JAVA coding and without Annotations
      ds = (DataSource) InitialContext.doLookup("jdbc/__default");
  or
      ds = (DataSource) InitialContext.doLookup("jdbc/rac");

How does it work ?
Code :
  @Resource(name="jdbc/rac")
   private DataSource ds;


Key Facts 
- Object variable DataSource ds will be initalized by using the @Resource Annotation from the container  
- This feature is called  Dependency Injection which is based on Reflection API 

Reference:

  • Professional entwickeln mit Java EE7  [ Verlag : Galileo Computing ]

Helmut’s RAC 11g/12c intial post

–> Use the above Menu to navigate around 300 RAC articles

Article Clusters:   Debug     12c-New-Feature    ASM   Clusterware     RAC    RAC-Performance   RAC-Networking   RAC-Tools

 

Recently updated articles :

XA : Java code for a simple TPM 12c: VIP/Application failover on LEAF Nodes 12c : Pluggable Databases
XA : RAC and Performane for XA Tx 12c/11g: Serverpools 12c: FLEX ASM 

 

Useful articles :                                                                                  Overview of all my 11g/12c RAC articles

A closer look on Cache Fusion II Debugging Node Eviction using TFA, CHM, OSWatcher Debugging Clusterware
Troubleshooting Clusterware startup problems Debugging Network problems using a bash script Recovering corrupted OLR, OCR
Performance: GES Locks and Deadlocks Performance: GC buffer busy aquire/release waits Performance: GCS log flush sync waits
Performance: LOG File SYNC waits
  • My initial blogging is about  my expieriences with  11.2.0.3/12.1  RAC systems on Linux
  • Most of the articles are using following infrastructure;  Virtualbox 4.2.14 on top of OEL 63/OEL64.
  • Use the Menubar to navigate through all the articles or press the HOME button of the menu to get displayed all  RAC related articles ( preferred method as can you get a quick overview  about all articles)
  • Note this Blog will not produce any new Post – only new pages will be added over time. This allows me to create a main menu where you can easily navigate and find  interested page grouped by  certain topics.

Disclaimer

  • This blog represent the work and opinions of the author and do not constitute official positions of my current employer Oracle  (working for the Oracle RAC support team ).
  • This material has been  reviewed, but author assume no responsibility whatsoever for the test cases.
  • If you corrupt your databases by running my scripts, you are solely responsible for that.