使用DG_broker工具管理DG之switchover
想到當時我做這個實驗的時候,由於在dg_broker工具使用switchover切換主備庫時候,忘記了具體語法,
官方文件找沒有講到,網上找也完全沒有太多的文章講到dg_broker工具管理DG的,有了文章,都是很粗糙的文章,
很難看的明白,關鍵是參照敲了語句上去,也是報錯,還一直嫌疑自己配錯了引數檔案CONFIGURATION,
試了幾個語句都不行,都切換不了。由於是凌晨了,心想放到明天再更改引數檔案再試一試。第二天,繼續這個測試,
心想著,要是弄出來了,一定要把switchover的測試過程放上去我的部落格裡。第二天更換了引數檔案還是不行,
想著額,難道是庫名那裡有問題,試了把switchover to 備庫名 的庫名用單引號括起,奇蹟出現了,主備庫切換了。
後面問了一些人說這個還是看版本的,說他當時做也是弄了很久。一下是測試過程使用DG_broker工具管理DG:
--主庫配置dg broker監聽並開啟:
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=ENMO_DGMGRL.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=ENMO))
(SID_DESC=
(GLOBAL_DBNAME=ORA11GR2)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=ORA11GR2))
)
SQL> alter system set dg_broker_start=true;
System altered.
--備庫配置dg broker監聽並開啟:
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=PROD_DGMGRL.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=PROD))
)
SQL> alter system set dg_broker_start=true;
System altered.
--登入DG——broker工具:
[oracle@oracle admin]$ export ORACLE_SID=ENMO
[oracle@oracle admin]$ dgmgrl #登入使用方法與rman相似
DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL>
DGMGRL>
DGMGRL> connect sys/oracle
Connected.
--首先把之前建立的引數檔案刪除REMOVE:
DGMGRL> REMOVE CONFIGURATION;
Removed configuration
DGMGRL> SHOW CONFIGURATION;
ORA-16532: Data Guard broker configuration does not exist
Configuration details cannot be determined by DGMGRL
DGMGRL>
--建立新的引數檔案CONFIGURATION:
DGMGRL> CREATE CONFIGURATION 'ENMO' as PRIMARY DATABASE IS 'ENMO' CONNECT IDENTIFIER IS ENMO;
Configuration "ENMO" created with primary database "ENMO"
--檢視引數檔案的狀態:
DGMGRL> SHOW CONFIGURATION;
Configuration - ENMO
Protection Mode: MaxAvailability
Databases:
ENMO - Primary database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
--新增備庫:
DGMGRL> ADD DATABASE 'PROD' AS CONNECT IDENTIFIER IS ENMO;
Error: ORA-16662: network timeout when contacting a database
Failed.
新增備庫錯誤。
--正確的新增方法:
DGMGRL> ADD DATABASE 'PROD' AS CONNECT IDENTIFIER IS PROD;
Database "PROD" added
--啟用引數檔案:
DGMGRL> ENABLE CONFIGURATION;
Enabled.
啟用成功。
--檢視引數檔案狀態:
DGMGRL> SHOW CONFIGURATION;
Configuration - ENMO
Protection Mode: MaxAvailability
Databases:
ENMO - Primary database
PROD - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
已經使用。
--啟用備庫PROD:
DGMGRL> ENABLE DATABASE 'PROD'
Enabled.
DGMGRL>
啟用成功。
--檢視備庫的狀態:
DGMGRL> SHOW CONFIGURATION;
Configuration - ENMO
Protection Mode: MaxAvailability
Databases:
ENMO - Primary database
PROD - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
--檢視詳細資訊:
DGMGRL> SHOW DATABASE 'PROD';
Database - PROD
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 0 seconds ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Apply Rate: 895.00 KByte/s
Real Time Query: ON
Instance(s):
PROD
Database Status:
SUCCESS
--檢視主庫或者備庫更詳細的資訊:
DGMGRL> SHOW DATABASE VERBOSE 'ENMO'; #同樣去檢視另外一個庫的狀態,只需修改唯一庫名
Database - ENMO
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
ENMO
Properties:
DGConnectIdentifier = 'enmo'
ObserverConnectIdentifier = ''
LogXptMode = 'SYNC'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '30'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'PROD, ENMO'
LogFileNameConvert = 'PROD, ENMO'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
ApplyLagThreshold = '0'
TransportLagThreshold = '0'
TransportDisconnectedThreshold = '30'
SidName = 'ENMO'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ENMO_DGMGRL.oracle.com)(INSTANCE_NAME=ENMO)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/home/oracle/arch/ENMO/'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
TopWaitEvents = '(monitor)'
--切換主備庫:
DGMGRL> switchover to 'PROD'; #這裡特別強調:to備庫名,有些版本不需加單引號括起,有些版本需要括起。
Performing switchover NOW, please wait...
Operation requires a connection to instance "PROD" on database "PROD"
Connecting to instance "PROD"...
Connected.
New primary database "PROD" is opening...
Operation requires startup of instance "ENMO" on database "ENMO"
Starting instance "ENMO"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "PROD"
--切換之後,檢視新的主庫與備庫資訊:
--檢視主庫狀態:
SQL> select database_role,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE
--檢視備庫的狀態:
SQL> select database_role,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY
--切換保護模式:
----重新調至最大可用模式:
DGMGRL> EDIT DATABASE 'PROD' SET PROPERTY 'LogXptMode'='ASYNC';
Property "LogXptMode" updated
DGMGRL> EDIT DATABASE 'ENMO' SET PROPERTY 'LogXptMode'='ASYNC';
Error: ORA-16805: change of LogXptMode property violates overall protection mode
Failed.
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;
Succeeded.
DGMGRL>
DGMGRL>
DGMGRL> show configuration;
Configuration - ENMO
Protection Mode: MaxPerformance
Databases:
PROD - Primary database
ENMO - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
最大可用模式切換成功。
官方文件找沒有講到,網上找也完全沒有太多的文章講到dg_broker工具管理DG的,有了文章,都是很粗糙的文章,
很難看的明白,關鍵是參照敲了語句上去,也是報錯,還一直嫌疑自己配錯了引數檔案CONFIGURATION,
試了幾個語句都不行,都切換不了。由於是凌晨了,心想放到明天再更改引數檔案再試一試。第二天,繼續這個測試,
心想著,要是弄出來了,一定要把switchover的測試過程放上去我的部落格裡。第二天更換了引數檔案還是不行,
想著額,難道是庫名那裡有問題,試了把switchover to 備庫名 的庫名用單引號括起,奇蹟出現了,主備庫切換了。
後面問了一些人說這個還是看版本的,說他當時做也是弄了很久。一下是測試過程使用DG_broker工具管理DG:
--主庫配置dg broker監聽並開啟:
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=ENMO_DGMGRL.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=ENMO))
(SID_DESC=
(GLOBAL_DBNAME=ORA11GR2)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=ORA11GR2))
)
SQL> alter system set dg_broker_start=true;
System altered.
--備庫配置dg broker監聽並開啟:
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=PROD_DGMGRL.oracle.com)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=PROD))
)
SQL> alter system set dg_broker_start=true;
System altered.
--登入DG——broker工具:
[oracle@oracle admin]$ export ORACLE_SID=ENMO
[oracle@oracle admin]$ dgmgrl #登入使用方法與rman相似
DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL>
DGMGRL>
DGMGRL> connect sys/oracle
Connected.
--首先把之前建立的引數檔案刪除REMOVE:
DGMGRL> REMOVE CONFIGURATION;
Removed configuration
DGMGRL> SHOW CONFIGURATION;
ORA-16532: Data Guard broker configuration does not exist
Configuration details cannot be determined by DGMGRL
DGMGRL>
--建立新的引數檔案CONFIGURATION:
DGMGRL> CREATE CONFIGURATION 'ENMO' as PRIMARY DATABASE IS 'ENMO' CONNECT IDENTIFIER IS ENMO;
Configuration "ENMO" created with primary database "ENMO"
--檢視引數檔案的狀態:
DGMGRL> SHOW CONFIGURATION;
Configuration - ENMO
Protection Mode: MaxAvailability
Databases:
ENMO - Primary database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
--新增備庫:
DGMGRL> ADD DATABASE 'PROD' AS CONNECT IDENTIFIER IS ENMO;
Error: ORA-16662: network timeout when contacting a database
Failed.
新增備庫錯誤。
--正確的新增方法:
DGMGRL> ADD DATABASE 'PROD' AS CONNECT IDENTIFIER IS PROD;
Database "PROD" added
--啟用引數檔案:
DGMGRL> ENABLE CONFIGURATION;
Enabled.
啟用成功。
--檢視引數檔案狀態:
DGMGRL> SHOW CONFIGURATION;
Configuration - ENMO
Protection Mode: MaxAvailability
Databases:
ENMO - Primary database
PROD - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
已經使用。
--啟用備庫PROD:
DGMGRL> ENABLE DATABASE 'PROD'
Enabled.
DGMGRL>
啟用成功。
--檢視備庫的狀態:
DGMGRL> SHOW CONFIGURATION;
Configuration - ENMO
Protection Mode: MaxAvailability
Databases:
ENMO - Primary database
PROD - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
--檢視詳細資訊:
DGMGRL> SHOW DATABASE 'PROD';
Database - PROD
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 0 seconds ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Apply Rate: 895.00 KByte/s
Real Time Query: ON
Instance(s):
PROD
Database Status:
SUCCESS
--檢視主庫或者備庫更詳細的資訊:
DGMGRL> SHOW DATABASE VERBOSE 'ENMO'; #同樣去檢視另外一個庫的狀態,只需修改唯一庫名
Database - ENMO
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
ENMO
Properties:
DGConnectIdentifier = 'enmo'
ObserverConnectIdentifier = ''
LogXptMode = 'SYNC'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '30'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'PROD, ENMO'
LogFileNameConvert = 'PROD, ENMO'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
ApplyLagThreshold = '0'
TransportLagThreshold = '0'
TransportDisconnectedThreshold = '30'
SidName = 'ENMO'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ENMO_DGMGRL.oracle.com)(INSTANCE_NAME=ENMO)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/home/oracle/arch/ENMO/'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
TopWaitEvents = '(monitor)'
--切換主備庫:
DGMGRL> switchover to 'PROD'; #這裡特別強調:to備庫名,有些版本不需加單引號括起,有些版本需要括起。
Performing switchover NOW, please wait...
Operation requires a connection to instance "PROD" on database "PROD"
Connecting to instance "PROD"...
Connected.
New primary database "PROD" is opening...
Operation requires startup of instance "ENMO" on database "ENMO"
Starting instance "ENMO"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "PROD"
--切換之後,檢視新的主庫與備庫資訊:
--檢視主庫狀態:
SQL> select database_role,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE
--檢視備庫的狀態:
SQL> select database_role,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY
--切換保護模式:
----重新調至最大可用模式:
DGMGRL> EDIT DATABASE 'PROD' SET PROPERTY 'LogXptMode'='ASYNC';
Property "LogXptMode" updated
DGMGRL> EDIT DATABASE 'ENMO' SET PROPERTY 'LogXptMode'='ASYNC';
Error: ORA-16805: change of LogXptMode property violates overall protection mode
Failed.
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;
Succeeded.
DGMGRL>
DGMGRL>
DGMGRL> show configuration;
Configuration - ENMO
Protection Mode: MaxPerformance
Databases:
PROD - Primary database
ENMO - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
最大可用模式切換成功。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31392094/viewspace-2126922/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【DG】DG之Switchover和Failover的區別AI
- Oracle:DG 的 switchoverOracle
- 物理DG角色轉換:switchover
- DG物理standby,switchover步驟
- 【DATAGUARD】物理dg的switchover切換(五)
- 一步一步搭建11gR2 rac+dg之DG SWITCHOVER功能(九)
- 【DG】Data Guard主備庫Switchover切換
- DG學習筆記(8)_Switchover and Failover筆記AI
- 單節點DG的switchover切換介紹
- Oracle 11g dg switchover切換操作流程Oracle
- ora11_node_dg(2)ADG做(switchover)切換測試
- 11gR2 RAC DB switchover using DG broker (文件 ID 880017.1)
- Oracle DG管理Broker配置Oracle
- kubernetes管理之使用yq工具擷取屬性
- DG中備庫為SWITCHOVER PENDING時是否能進行主備切換
- DG物理standby,Failover之後原primary重回DGAI
- 【DG】Oracle之級聯DG--(cascade dg) --(一主一備一級聯)Oracle
- Oracle DG管理Redo Transport服務Oracle
- ORACLE DG之備庫角色Oracle
- 【DG】之 Snapshot standby模式模式
- 資訊、檔案管理之工具論
- Oracle 12c DG管理-分離SYS特權使用者Oracle
- DataGuard SwitchOver
- 使用 GVM 工具管理 Go 版本Go
- 【asmcmd】使用asmcmd工具管理ASMASM
- DataGuard---->物理StandBy的角色切換之switchover
- iOS逆向之工具使用iOS
- Oracle DG Broker配置的管理週期Oracle
- Oracle DG管理資料庫屬性Oracle資料庫
- Oracle DG環境中的管理操作Oracle
- 【DG】Oracle 19c使用dbca來搭建物理DGOracle
- ORACLE DG之引數詳解Oracle
- rac庫與單機physical standby 之間的switchover
- openGauss主備切換之switchover與failoverAI
- 【DG】備庫RMAN還原方式搭建DG(不使用duplicate命令)
- 再次使用DGbroker做switchover主備切換
- 版本管理工具之Git 和SVNGit
- SAP-PM 工具管理篇之出入庫