Recently, i did an RAC validation with our oracle partner and encountered this weird exception called "Io exception: The Network Adapter could not establish the connection".
Two client machine were running same java code (using jdbc thin driver & oracle datasource) in the same LAN as RAC servers, but they came out with differen behaviour. One could connect to RAC database, the other one always got io exception mentioned above.
The only difference between two machines was one of clients' host file having rac ip & hostname mapping entry, which is able to connect to oracle rac db.
Something weird is that all db clients and servers were actually sitting in the same LAN. I could ping and telnet db rac with rac ip address (virtual and real ) from client machines, but when i use ip address in the java class to lookup the db connection, i could not get connected to db if rac ip & hostname mapping entries were not available in the client host file.
Here is the sample Codes for RAC FCF connection:
OracleDataSource ods = new OracleDataSource();
OracleConnectionCacheManager occm = null;
ods.setUser("user-name");
ods.setPassword("password");
String cacheName = "cache";
String dbURL="jdbc:oracle:thin:@"+
"(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=ON)" +
"(ADDRESS=(PROTOCOL=TCP)" +
"(HOST=rac1-vip-address)(PORT=1521))" +
"(ADDRESS=(PROTOCOL=TCP)" +
"(HOST=rac2-vip-address)(PORT=1521)))" +
"(CONNECT_DATA=(SERVICE_NAME=orcl.abc.com)))";
ods.setURL(dbURL); System.out.println("Url=" + dbURL ); ods.setConnectionCachingEnabled(true);
Properties prop = new Properties();
prop.setProperty("MinLimit", "5");
prop.setProperty("MaxLimit", "40");
prop.setProperty("InitialLimit", "10");
prop.put (oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR,"" + (5000)); // 5000ms ods.setConnectionCacheProperties(prop);
ods.setFastConnectionFailoverEnabled(true);
ods.setONSConfiguration("nodes=rac1-ip-address:6200,rac2-ip-address:6200"); ods.setConnectionCacheName(cacheName);
//occm = OracleConnectionCacheManager.getConnectionCacheManagerInstance();
Connection conn = ods.getConnection();
It looks somewhere JDBC driver looking up db connection with rac hostname instead of ip address and I have to put the rac ip & hostname mapping in the client host file for jdbc driver to resolve them.
Highscalability is Up For Sale
1 year ago
2 comments:
amazing stuff thanx :)
i really love your own posting taste, very unique.
don't give up and also keep writing in all honesty , because it simply just truly worth to look through it.
looking forward to look over additional of your current article content, enjoy your day ;)
Post a Comment