Oracle 11g RAC ORA-12505

xz43發表於2013-04-09
以前使用oracle的RAC都是透過連線資料庫的URL做文章,把RAC的多個節點都配置到該URL裡面。11g開始,提供了新玩法,避免由於RAC中節點的增、減而去調整資料來源的URL引數。11g提供了透過scan ip訪問的方式,本以為這個和單例項資料庫一樣連線使用,結果報錯:
java.sql.SQLException: Listener refused the connection with the following error:

ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
zhscan:1521:racdb

        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
        at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:439)
        at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
        at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:68)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:87)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:83)
        at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:884)
        at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:601)
        at com.mchange.v2.resourcepool.BasicResourcePool.access$400(BasicResourcePool.java:31)
        at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1079)
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)

把這個zhscan改為scan ip,錯誤依舊。

如是,配置資料庫連線到RAC的某一個節點上,且使用該節點上的例項racdb1,資料庫連線成功。

透過客戶端的sqlplus連線racdb,一切正常。再透過plsql連線,也沒問題。

既然客戶端可以連,那證明oracle RAC沒問題,是配置資料來源連線池時的引數問題。於是,找到客戶端伺服器下的tnsnames.ora,找到裡面配置的racdb那段作為URL後半部分,整個資料來源的URL如下:
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.100)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=racdb)))

其中192.168.1.100是RAC的scan ip,racdb是GLOBAL_DBNAME。
按如上配置儲存後,資料庫連線成功。
看來,雖然11g提供了scan ip訪問的方式,但並不是像想象著訪問單例項那樣玩了。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9399028/viewspace-758106/,如需轉載,請註明出處,否則將追究法律責任。

相關文章