方法1: (LOAD_BALANCE=false)
How to Setup EUS and TNS for Failover Configuration of Oracle Dataguard with Primary and Standby Hosts (Doc ID 2224611.1) | 编辑To Bottom |
In this Document APPLIES TO:Oracle Unified Directory - Version 11.1.2.3.0 and laterAdvanced Networking Option - Version 11.2.0.3 and later Oracle Internet Directory - Version 11.1.1.9.0 and later Information in this document applies to any platform. GOALTo implement EUS in a Data Guard with Primary/Standby database and create TNS aliases for failover SOLUTIONPurposeThe purpose of this article is to explain how to configure Enterprise User Security (EUS) with a TNS connect string to work correctly with Data Guard with Primary/Standby databases on different physical hosts connecting to a directory server (OUD or OID). ScopeIntegration with EUS, 11g and 12c Oracle Databases, and OUD or OID. The features described in this article applies to OUD 11gR2PS3 or OID 11gR1PS7 and onwards. DetailsProblem 2) Create global schema for both databases. 2.1) Create schema mapping within an enterprise domain in the (OUD/OID) directory. 3) Create global roles in both databases and grant privileges to them. 3.1) Create enterprise roles in (OUD/OID) and assign primary and standby databases to both of them. 3.2) Grant enterprise roles to LDAP groups in (OUD/OID). 4) Test EUS, connecting to each of databases using registered service names from primary or secondary databases. 5) Create an additional TNS entry for failover mechanism as follows -
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ) ) Note: This is an example of a configuration and the service name might be different on each server. Add the following Failover entry to tnsnames.ora DB11G= (DESCRIPTION_LIST= (FAILOVER=true) (LOAD_BALANCE=false) (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST= (CONNECT_DATA= (SERVICE_NAME= ) (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST= (CONNECT_DATA= (SERVICE_NAME= ) ) This entry can be exported to OUD using either "netmgr" or enterprise manager .
Choose the TNS name "DB11g" to be exported to OUD In Directory (OUD or OID) find the corresponding entries as follows: dn: cn= orclNetDescString: (DESCRIPTION_LIST=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST= ) objectClass: orclNetService objectClass: top cn: orclNetDescName: 000:cn=DESCRIPTION_LIST_0 dn: cn=DESCRIPTION_LIST_0,cn= orclNetDescList: 000:cn=DESCRIPTION_0 orclNetDescList: 001:cn=DESCRIPTION_1 orclVersion: v0.0 objectClass: orclNetDescriptionList objectClass: top orclNetShared: NO cn: DESCRIPTION_LIST_0 dn: cn=DESCRIPTION_0,cn=DESCRIPTION_LIST_0,cn= orclNetServiceName: orclVersion: v0.0 objectClass: orclNetDescriptionAux1 objectClass: orclNetDescription objectClass: top orclNetLoadBalance;binary: NO orclNetAddrList: 000:cn=ADDRESS_LIST_0 orclNetShared: NO cn: DESCRIPTION_0 dn: cn=ADDRESS_LIST_0,cn=DESCRIPTION_0,cn=DESCRIPTION_LIST_0,cn= orclNetSourceRoute;binary: NO orclNetFailover;binary: YES orclVersion: v0.0 objectClass: orclNetAddressList objectClass: top orclNetLoadBalance;binary: NO orclNetAddrList: 000:cn=ADDRESS_0 orclNetShared: NO cn: ADDRESS_LIST_0 dn: cn=ADDRESS_0,cn=ADDRESS_LIST_0,cn=DESCRIPTION_0,cn=DESCRIPTION_LIST_0,cn= orclNetProtocol: TCP orclVersion: v0.0 objectClass: orclNetAddress objectClass: top orclNetShared: NO cn: ADDRESS_0 orclNetAddressString: (ADDRESS=(PROTOCOL=TCP)(HOST= dn: cn=DESCRIPTION_1,cn=DESCRIPTION_LIST_0,cn= orclNetServiceName: orclVersion: v0.0 objectClass: orclNetDescriptionAux1 objectClass: orclNetDescription objectClass: top orclNetLoadBalance;binary: NO orclNetAddrList: 000:cn=ADDRESS_LIST_0 orclNetShared: NO cn: DESCRIPTION_1 dn: cn=ADDRESS_LIST_0,cn=DESCRIPTION_1,cn=DESCRIPTION_LIST_0,cn= orclNetSourceRoute;binary: NO orclNetFailover;binary: YES orclVersion: v0.0 objectClass: orclNetAddressList objectClass: top orclNetLoadBalance;binary: NO orclNetAddrList: 000:cn=ADDRESS_0 orclNetShared: NO cn: ADDRESS_LIST_0 dn: cn=ADDRESS_0,cn=ADDRESS_LIST_0,cn=DESCRIPTION_1,cn=DESCRIPTION_LIST_0,cn= orclNetProtocol: TCP orclVersion: v0.0 objectClass: orclNetAddress objectClass: top orclNetShared: NO cn: ADDRESS_0 orclNetAddressString: (ADDRESS=(PROTOCOL=TCP)(HOST=
6) Test the new TNS entry or log on to database # tnsping # sqlplus 7) Failover can be tested by stopping the primary server. Current and new sessions will automatically switch to the failover server on (in this example) |
方法2: (CONNECT_TIMEOUT=10)(RETRY_COUNT=3)
If you have a Maximum Availability Architecture (MAA) environment implemented, in which you use Oracle RAC for both your primary and standby Databases that are synchronized using Oracle Data Guard, then using the SCAN provides a simplified TNSNAMES configuration that a client can use to connect to the Database, independent of whether the primary or standby Database is the currently active Database.
To use this simplified configuration, Oracle Database 11g Release 2 introduced the following two SQL*Net parameters that can be used for connection strings of individual clients:
* The CONNECT_TIMEOUT parameter
It specifies the timeout duration in seconds for a client to establish an Oracle Net connection to an Oracle Database. This parameter overrides the SQLNET.OUTBOUND_CONNECT_TIMEOUT parameter in the SQLNET.ORA file.
* The RETRY_COUNT parameter
It specifies the number of times an ADDRESS_LIST is traversed before the connection attempt is terminated.
Using these two parameters, both the SCANs, the one on the primary site and the one on the standby site, can be used in the client connection strings. Also, if the randomly selected address points to the site that is not currently active, then the timeout enables the connection request to failover before the client waits for an unreasonably long time. The following example shows a sample TNSNAMES.ORA entry for a MAA environment:
sales.example.com =(DESCRIPTION= (CONNECT_TIMEOUT=10)(RETRY_COUNT=3)
(ADDRESS_LIST= (LOAD_BALANCE=on)(FAILOVER=ON)
(ADDRESS=(PROTOCOL=tcp)(HOST=sales1-scan)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=sales2-scan)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME= salesservice.example.com)))
The Net description string in this case is:
(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=
So, since there is no CONNECT_TIMEOUT defined, the connection is not redirected to the primary site where the database instance is active. This causes the TNS-12514 error and the client to wait for an unreasonable long time before failing over to the active site.
Add CONNECT_TIMEOUT and RETRY_COUNT parameters to the JDBC description string. That is:
jdbc:oracle:thin:@(DESCRIPTION=(CONNECT_TIMEOUT=10)(RETRY_COUNT=3)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=