复习ONS与Load Balance
[hr] | |||||
| 修改时间 26-MAY-2011 类型 FAQ 状态 PUBLISHED | |||||
Purpose
Questions and Answers
When the JDBC creates connections through FCF/ONS why do we see 2 connections/details on the OS level using netstat ( one with port 6200 and one server process 1521)?
Can you explain how ONS works with the JDBC driver?
What happens if the ONS service is not running, will the client connection fail or will it still connect to the database (port 1521) and put a warning message on the application log?
References
[hr]
Applies to:JDBC - Version: 10.2.0.1 to 10.2.0.4 - Release: 10.2 to 10.2
Information in this document applies to any platform.
***Checked for relevance on 26-May-2011***PurposeSimple questions about how ONS and FCF work with JDBC
Questions and AnswersWhen the JDBC creates connections through FCF/ONS why do we see 2 connections/details on the OS
level using netstat ( one with port 6200 and one server process 1521)?Port 1521
Port 1521 is the standard port through which the driver will interface with the database listener
to request database connections.
This is specified in the JDBC URL and takes place when the JDBC program is getting a new connection:
example:
[backcolor=rgb(238, 243, 247)]myDataSource.setURL(""jdbc
racle
ci:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=cluster_alias)(PORT =1521))(CONNECT_DATA=(SERVICE_NAME=service_name)))"
; Connection conn = myDataSource.getConnection();
[/backcolor]
On the database side, the database listener must be configured for this port (lsnrctl stat )
Port 6200
This must be the port that is configured by your RAC and application for the ONS service.
On the JDBC application side, the JDBC driver is made to subscribe to the service by using a call
such as :
[backcolor=rgb(238, 243, 247)]ods.setONSConfiguration("nodes=racnode1.example.com:6200,racnode2.example.com:6200"
; [/backcolor]
It is possible to make the JDBC driver subscribe to a local ONS service running on the client
however more commonly the driver will directly subscribe to the remote ONS service provided by the
RAC nodes such as in the example above.
On the database-side you will notice that the ONS service is running by using the command:
onsctl ping
example:
[backcolor=rgb(254, 252, 238)]$ onsctl ping
Number of onsconfiguration retrieved, numcfg = 2
onscfg[0]
{node = maple1, port = 6200}
Adding remote host maple1:6200
onscfg[1]
{node = maple2, port = 6200}
Adding remote host maple2:6200
ons is running ...
[/backcolor]
Can you explain how ONS works with the JDBC driver? The purpose for the driver to subscribe to ONS services is to enable Fast Connection Failover and
Run-time Load Balancing.
When a RAC node goes down, the JDBC driver is immediately aware of this by receiving a FAN event
for the node down . The driver is then capable of propagating this event by raising a
java.sql.SQLException: Closed Connection ( ORA-17008) to all the connections held by the driver
that are based on this node. For connections actively in use, the application typically handles
this situation by re-acquiring new connections from the connection cache. The cache itself will
handle unused connections that were affected by this event by rebuilding new connections on the
remaining RAC nodes when necessary.
When the application requests connections from the connection cache, the driver will chose a
cached connection based on the best known performance of the RAC node on which the connection is
based. This is possible because the driver receives via the ONS subscription performance
summaries of the RAC nodes that are registered to the ONS service.
For more details please refer to:
Oracle® Database JDBC Developer's Guide and Reference
10g Release 2 (10.2)
Part Number B14355-02
Section 24 Run-Time Connection Load Balancing
Section 27 Fast Connection Failover
What happens if the ONS service is not running, will the client connection fail or will it still connect to the database (port 1521) and put a warning message on the application log?
The main JDBC thread will keep running and the connections will works, You will be however
getting Exceptions from the ONS daemon thread:
[backcolor=rgb(254, 252, 238)]-----------
D:\jdev10134\jdk\bin\javaw.exe -client -classpath
D:\testcases\MapleTest\Project1\classes;D:\Drivers\10.2.0.4\ojdbc14.jar;D:\Drivers\ons.jar;D:\testca
ses\MapleTest\Project1 FCFConnectionCacheExample
>>PROGRAM using JDBC thin driver no oracle client required
>>ojdbc14.jar and ons.jar must be in the CLASSPATH
>>Press CNTRL C to exit running program
-----------
Instance -> orcl2
Host -> maple2
Service -> orcl.maple.com
NumberOfAvailableConnections: 9
NumberOfActiveConnections: 1
-----------
-----------
Instance -> orcl2
Host -> maple2
Service -> orcl.maple.com
NumberOfAvailableConnections: 9
NumberOfActiveConnections: 1
-----------
Exception in thread "Thread-5" oracle.ons.SubscriptionException: Subscription request timed out
after 30000 millseconds. Possible causes: OPMN may not be running, you may have an OPMN running
in an alternate ORACLE_HOME using duplicate port values, or OPMN may be misconfigured.
at oracle.ons.SubscriptionNotification.waitForReply(SubscriptionNotification.java:82)
at oracle.ons.ONS.addSubscriber(ONS.java:669)
at oracle.ons.Subscriber.realStartup(Subscriber.java:104)
at oracle.ons.Subscriber.
at
oracle.jdbc.pool.OracleRuntimeLoadBalancingEventHandlerThread$1.run(OracleRuntimeLoadBalancingEventH
andlerThread.java:74)
at java.security.AccessController.doPrivileged(Native Method)
at
oracle.jdbc.pool.OracleRuntimeLoadBalancingEventHandlerThread.run(OracleRuntimeLoadBalancingEventHan
dlerThread.java:66)
-----------
Instance -> orcl2
Host -> maple2
Service -> orcl.maple.com
NumberOfAvailableConnections: 9
NumberOfActiveConnections: 1
-----------
Exception in thread "Thread-4" oracle.ons.SubscriptionException: Subscription request timed out
after 30000 millseconds. Possible causes: OPMN may not be running, you may have an OPMN running
in an alternate ORACLE_HOME using duplicate port values, or OPMN may be misconfigured.
at oracle.ons.SubscriptionNotification.waitForReply(SubscriptionNotification.java:82)
at oracle.ons.ONS.addSubscriber(ONS.java:669)
at oracle.ons.Subscriber.realStartup(Subscriber.java:104)
at oracle.ons.Subscriber.
at
oracle.jdbc.pool.OracleFailoverEventHandlerThread$1.run(OracleFailoverEventHandlerThread.java:69)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.pool.OracleFailoverEventHandlerThread.run(OracleFailoverEventHandlerThread.java:61)
-----------
Instance -> orcl2
Host -> maple2
Service -> orcl.maple.com
NumberOfAvailableConnections: 9
NumberOfActiveConnections: 1
-----------
-----------
Instance -> orcl2
Host -> maple2
Service -> orcl.maple.com
NumberOfAvailableConnections: 9
NumberOfActiveConnections: 1
-----------
Process exited.
>>
>>
>>
Please refer to Note 433827.1 for running the above demo. In this instance, the demo ran without errors when the ONS service was up and only produces the exceptions when the ONS service was shutdown:
ReferencesNOTE:386752.1 - Step By Step Description On Setting Up FAN And FCF
NOTE:433827.1 - How to Verify and Test Fast Connection Failover (FCF) Setup from a JDBC Thin Client Against a 10.2.x RAC Cluster
相关内容[hr]产品[hr]
| ||
返回页首
相关内容