Configure Client Failover For Dataguard Connections Using DB Services-1429223.1
How To Configure Client Failover For Dataguard Connections Using Database Services (文件 ID 1429223.1)
In this Document
Goal |
Solution |
Pre 11.2 Configuration: |
Configuration in 11.2 or later release: |
Applies to:
Oracle Database - Enterprise Edition - Version 10.2.0.1 to 11.2.0.3 [Release 10.2 to 11.2]Information in this document applies to any platform.
Goal
In a Data Guard environment you have primary database which is open in read write mode and the standby database which can be in mount mode or open in read only mode for reporting purpose.
This document describes how to setup clients to connect to Data Guard databases (primary and standby) and configure automatic client failover such that in case there is role change due to switchover or failover, the client connections should still be valid i.e. the clients that need to connect to read only standby should always connect to the current standby irrespective of which database in the Data Guard configuration is currently in standby role and same for primary connections.
This goal is achieved via database services.
In 11gR2, we have the concept of role-based database services. For Data Guard environments running older release, this is achieved via a database startup trigger.
Pre 11.2 Configuration
11.2 or later Configuration
Solution
Pre 11.2 Configuration:
+ On the current primary, create 2 services, one to connect to the primary (prim_db) and another (stby_db) to connect to the read only standby:
SQL> exec dbms_service.create_service('prim_db','prim_db'); SQL> exec dbms_service.create_service('stby_db','stby_db');
+ On the current primary, start the service that is needed to connect to primary:
SQL> exec dbms_service.start_service('prim_db');
+ Now, on the current primary, create the trigger to manage these services accordingly:
CREATE OR REPLACE TRIGGER startDgServices after startup on database DECLARE db_role VARCHAR(30); db_open_mode VARCHAR(30); BEGIN SELECT DATABASE_ROLE, OPEN_MODE INTO db_role, db_open_mode FROM V$DATABASE; IF db_role = 'PRIMARY' THEN DBMS_SERVICE.START_SERVICE('prim_db'); END IF; IF db_role = 'PHYSICAL STANDBY' AND db_open_mode LIKE 'READ ONLY%' THEN DBMS_SERVICE.START_SERVICE('stby_db'); END IF; END; /
+ Note down the current online redo log sequence on primary and switch the current logfile:
SQL> select thread#, sequence# from v$log where status = 'CURRENT'; SQL> alter system archive log current;
Ensure that the archive with sequence# which was shown as current is shipped and applied on standby. This ensures that the redo from CREATE TRIGGER command is applied on standby.
Now, shutdown and startup the standby database to make the trigger take effect:
SQL> shut immediate; SQL> startup;
.
+ Configure client TNSNAMES.ORA entry. In below example PRIM_DB should be used by clients that need to connect to primary database. STBY_DB should be used by clients that need to access the read only standby database:
PRIM_DB = (DESCRIPTION = (ADDRESS_LIST = (FAILOVER = ON) (LOAD_BALANCE = OFF) (ADDRESS = (PROTOCOL = TCP)(HOST = primary.oracle.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = standby.oracle.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = prim_db) ) ) STBY_DB = (DESCRIPTION = (ADDRESS_LIST = (FAILOVER = ON) (LOAD_BALANCE = OFF) (ADDRESS = (PROTOCOL = TCP)(HOST = primary.oracle.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = standby.oracle.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = stby_db) ) )
Configuration in 11.2 or later release:
We will be using role-based database services introduced in 11.2. To use role-based services, Oracle Clusterware must be installed and active on the primary and standby sites for both single instance (using Oracle Restart) and Oracle RAC databases.
+ On the primary and standby hosts create the service (prim_db) that the clients will use to connect to the primary database. The service should be created such that it is associated with and runs on the database when it is in the ‘PRIMARY’ database role:
[oracle@vmOraLinux6 ~]$ srvctl add service -d ora11gR2 -s prim_db -l PRIMARY -e SESSION -m BASIC -w 10 -z 10
On standby:
[oracle@vmOraLinux6 ~]$ srvctl add service -d sby11gR2 -s prim_db -l PRIMARY -e SESSION -m BASIC -w 10 -z 10
+ Start the primary database service (prim_db) on the current primary:
+ Next, on the primary and standby hosts create the service (stby_db) that the clients will use to connect to the read only standby database. The service should be created such that it is associated with and runs on the database when it is in the ‘PHYSICAL_STANDBY’ database role:
[oracle@vmOraLinux6 ~]$ srvctl add service -d ora11gR2 -s stby_db -l PHYSICAL_STANDBY -e SESSION -m BASIC -w 10 -z 10
On standby:
[oracle@vmOraLinux6 ~]$ srvctl add service -d sby11gR2 -s stby_db -l PHYSICAL_STANDBY -e SESSION -m BASIC -w 10 -z 10
+ Now, start the standby service (stby_db) on standby host:
+ Configure client TNSNAMES.ORA entry. In below example PRIM_DB should be used by clients that need to connect to primary database. STBY_DB should be used by clients that need to access the read only standby database:
(DESCRIPTION =
(ADDRESS_LIST =
(FAILOVER = ON)
(LOAD_BALANCE = OFF)
(ADDRESS = (PROTOCOL = TCP)(HOST = primary.oracle.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = standby.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = prim_db)
)
)
STBY_DB =
(DESCRIPTION =
(ADDRESS_LIST =
(FAILOVER = ON)
(LOAD_BALANCE = OFF)
(ADDRESS = (PROTOCOL = TCP)(HOST = primary.oracle.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = standby.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = stby_db)
)
)
Also see the MAA Whitepaper "Client Failover Best Practices for Data Guard 11g Release 2" for further Details and Reference.
|
|
- Oracle Database Products > Oracle Database > Oracle Database > Oracle Database - Enterprise Edition > Oracle Data Guard > Active Data Guard
- Oracle Database Products > Oracle Database > Oracle Database > Oracle Database - Enterprise Edition > Oracle Data Guard > All Physical Standby Issues
- Oracle Database Products > Oracle Database > Oracle Database > Oracle Database - Enterprise Edition > Oracle Data Guard > Client Fail Over
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17252115/viewspace-775589/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- How to configure Client Failover after Data Guard Switchover or Failover [ID 316740.1]clientAI
- DataGuard:Physical Standby FailoverAI
- Oracle dataguard failover 實戰OracleAI
- 10g_dataguard_failoverAI
- DataGuard:Logical Standby FailoverAI
- redis_failover - Automatic Redis Failover Client/ServerRedisAIclientServer
- 【ASK_ORACLE】手動配置DataGuard的自動化Client Failover(故障轉移)的serviceOracleclientAI
- Dataguard failover切換實驗AI
- DataGuard模擬FailOver實驗AI
- Install 11.2/12.1 DB/Client in Silent Mode without Using Response File _885643.1client
- Oracle Dataguard故障轉移(failover)操作OracleAI
- dataguard switchover & failover steps (rac)AI
- oracle11g dataguard完全手冊--failover &active dataguard(完)OracleAI
- configure Django db settingDjango
- Failover 之 Client-Side Connect time Failover、Client-Side TAF、Service-Side TAFAIclientIDE
- cassandra0.5 remote client access configureREMclient
- dataguard之物理standby庫failover 切換AI
- 【DataGuard】物理Data Guard之Failover轉換AI
- 【DATAGUARD】物理dg的failover切換(六)AI
- How To Configure Server Side Transparent Application FailoverServerIDEAPPAI
- RAC+Dataguard環境中JDBC Failover配置JDBCAI
- 11g DataGuard實現故障轉移(Failover)AI
- How to configure SAP connections with Connection Transmitter Over air_part1MITAI
- Configure Oracle Dataguard Primary-ASM to Physical-ASM薦OracleASM
- ORACLE 11G DataGuard Failover後如何修復standby庫OracleAI
- Oracle 9i DataGuard Failover 發生ORA-16139OracleAI
- Oracle 10g DataGuard物理主備切換-switchover與failoverOracle 10gAI
- How to Configure TAF and Client Load Balancing in a Replicated Environment [ID 210596.1]client
- Oracle RAC Failove 之一:Client-Side Connect Time FailoverOracleAIclientIDE
- Local Connections and Secure Remote Connections (36)REM
- Oracle DataGuard環境failover後通過舊備份建立物理StandbyOracleAI
- 一步一步學DataGuard(15)邏輯standby之failoverAI
- Oracle DB OS Install and Configure Requirements Quick Reference (8.0.5 to 11.2)OracleUIREM
- 11R2-DataGuard Scenarios.Failover後配置邏輯備庫iOSAI
- oracle 10gR2 dataguard db_unique_name parameterOracle 10g
- ORA-19909(一次DataGuard Failover導致的故障AI
- 引數配置 -- 最大效能模式 dataguard 不影響Production DB .模式
- mysql的max_connections和Too many connectionsMySql