- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
3#
发表于 2012-2-2 22:36:34
Question 2 :使用11G的SCAN-NAME来连接的话,有没有什么特殊要求啊?我这边是纯JDBC.THIN。。
没有大规模使用 , 不是很了解 参考以下文档
What is SCAN ? Which version of JDBC supports SCAN ?
SCAN or Single Client Access Name is a new Oracle Real Application Clusters (RAC) 11g Release 2 feature that provides a single name for clients to access an Oracle Database running in a cluster. The benefit is clients using SCAN do not need to change if you add or remove nodes in the cluster. Having a single name to access the cluster allows clients to use the EZConnect client and the simple JDBC thin URL to access any database running in the clusters independently of which server(s) in the cluster the database is active. SCAN provides load balancing and failover of client connections to the database. The SCAN works as an IP alias for the cluster.
A typical JDBC URL using SCAN would look like:
jdbc:oracle:thin:@sales1-scan:1521/oltp
Additional Reading:
http://www.oracle.com/technetwor ... iew/scan-129069.pdf
SCAN feature is supported only from JDBC version 11.2.0.1. This was one of the features added to 11.2 as a part of "IPv6 support".- Using SCAN With Oracle JDBC 11g Thin Driver [ID 1290193.1]
- Applies to:
- JDBC - Version: 11.1.0.7 to 11.2.0.2.0 - Release: 11.1 to 11.2
- Information in this document applies to any platform.
- Goal
- With the introduction of 11g r2 RDBMS RAC, clusters can be created using SCAN (Single Client Access Name) as described in this white paper below:
- http://www.oracle.com/technetwork/database/clustering/overview/scan-129069.pdf
- In this how to, we use a SCAN JDBC URL to verify that we can load balance connections to the RAC nodes using a SCAN address.
- Solution
- Verify SCAN Setup
- Log into one of you RAC nodes and verify the tnsnames.ora entry for your service as shown below. If you have a valid service created, there will exist an entry in your $ORACLE_HOME/network/admin/tnsnames.ora file.
- pas_srv =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = apctcsol1)(PORT = 1521))
- (LOAD_BALANCE = YES)
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = pas_srv)
- )
- )
- Test using SQL*Plus as shown below to verify you can connect.
- [oradb1@auw2k3 admin]$ sqlplus scott/tiger@pas_srv
- SQL*Plus: Release 11.2.0.2.0 Production on Tue Feb 1 09:23:03 2011
- Copyright (c) 1982, 2010, Oracle. All rights reserved.
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
- With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
- Data Mining and Real Application Testing options
- SQL>
- Run some SQL as follows to check the instance you are connected to.
- SQL> col "Instance" format a25
- SQL> col "Hostname" format a25
- SQL> col "Service" format a25
- SQL> select sys_context('userenv', 'instance_name') as "Instance",
- 2 sys_context('userenv', 'server_host') as "Hostname",
- 3 sys_context('userenv', 'service_name') as "Service"
- 4 from dual;
- Instance Hostname Service
- ------------------------- ------------------------- -------------------------
- A12 auw2k4 pas_srv
- SQL>
- Repeat #2 and #3 to verify you are load balancing nodes from SQL*Plus.
- SQL> col "Instance" format a25
- SQL> col "Hostname" format a25
- SQL> col "Service" format a25
- SQL>
- SQL> select sys_context('userenv', 'instance_name') as "Instance",
- 2 sys_context('userenv', 'server_host') as "Hostname",
- 3 sys_context('userenv', 'service_name') as "Service"
- 4 from dual;
- Instance Hostname Service
- ------------------------- ------------------------- -------------------------
- A11 auw2k3 pas_srv
- Determine the SCAN host/port by connecting to any of the RAC instances in the cluster as shown below.
- SQL> show parameter remote_listener
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- remote_listener string apctcsol1:1521
- SQL>
- Check the SCAN listener is running as shown by the 2 commands below.
- [oradb1@auw2k3 admin]$ srvctl config scan_listener
- SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
- [oradb1@auw2k3 admin]$ srvctl status scan_listener
- SCAN Listener LISTENER_SCAN1 is enabled
- SCAN listener LISTENER_SCAN1 is running on node auw2k3
- [oradb1@auw2k3 ~]$ srvctl config scan
- SCAN name: apctcsol1, Network: 1/10.187.80.0/255.255.254.0/eth1
- SCAN VIP name: scan1, IP: /apctcsol1.au.oracle.com/10.187.80.129
- Steps
- The following demo can be run to verify your SCAN JDBC URL is load balancing between the RAC nodes.
- Download the 11.2.0.2 JDBC driver "ojdbc6.jar" from the following location
- http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
- Ensure you have JDK 1.6 in your path
- C:\temp\notes>java -version
- java version "1.6.0_21"
- Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
- Java HotSpot(TM) 64-Bit Server VM (build 17.0-b17, mixed mode)
- Download the source code below onto your file system in the same directory where you have "ojdbc6.jar"
- LoadBalanceTestSCAN.java
- File system would look as follows.
- C:\temp\notes>dir
- Volume in drive C is OS
- Volume Serial Number is 7C37-0C64
- Directory of C:\temp\notes
- 01/02/2011 01:12 PM <DIR> .
- 01/02/2011 01:12 PM <DIR> ..
- 01/02/2011 01:12 PM 3,271 LoadBalanceTestSCAN.java
- 14/10/2010 09:22 AM 2,152,051 ojdbc6.jar
- 3 File(s) 2,158,900 bytes
- 2 Dir(s) 249,171,558,400 bytes free
- Edit the code below to specify your SCAN JDBC URL and database username and password.
- public final String userId = "scott";
- public final String password = "tiger";
- private static final String url =
- "jdbc:oracle:thin:@apctcsol1.au.oracle.com:1521/pas_srv";
- Note: The format of the JDBC URL is as follows.
- jdbc:oracle:thin:@{scan-listener-hostname}:{port}/{service-name}
- You could also use a URL as follows.
- jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=apctcsol1.au.oracle.com)(PORT=1521))(LOAD_BALANCE=YES)(CONNECT_DATA=
- (SERVER=DEDICATED)(SERVICE_NAME=pas_srv)))
- 6. Compile as follows.
- C:\temp\notes>javac -cp ojdbc6.jar;. LoadBalanceTestSCAN.java
- Run as follows.
- C:\temp\notes>java -cp ojdbc6.jar;. LoadBalanceTestSCAN
- Test Started at Tue Feb 01 13:12:46 EST 2011
- Obtaining 5 connections
- using URL : jdbc:oracle:thin:@apctcsol1.au.oracle.com:1521/pas_srv
- =============
- Database Product Name is ... Oracle
- Database Product Version is Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
- With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
- Data Mining and Real Application Testing options
- =============
- JDBC Driver Name is ........ Oracle JDBC driver
- JDBC Driver Version is ..... 11.2.0.2.0
- JDBC Driver Major Version is 11
- JDBC Driver Minor Version is 2
- =============
- Connection #0 : instance[A11], host[auw2k3], service[pas_srv]
- Connection #1 : instance[A12], host[auw2k4], service[pas_srv]
- Connection #2 : instance[A11], host[auw2k3], service[pas_srv]
- Connection #3 : instance[A12], host[auw2k4], service[pas_srv]
- Connection #4 : instance[A12], host[auw2k4], service[pas_srv]
- Closing Connections
- Test Ended at Tue Feb 01 13:12:47 EST 2011
- If you find the JDBC Thin does not load balance among the available scan vips/listeners. Then you could be hitting the following unpublished bug 8812294 - TB: PERFORMANCE: JDBC THIN NOT LOAD-BALANCING AMONG SCAN IP'S
复制代码 |
|