由于之前的switchover失败,后手工恢复了错误。导致 dg broker的配置文件显示的是错误的,db131现在已经是备库了,而dg broker配置文件还是显示是primary database.
主备库看到的错误是不一样的,db131配置信息显示 db132是主库,db132显示的db131是主库。
DB131:
DGMGRL> show configuration;
Configuration - dg_test11
Protection Mode: MaxPerformance
Databases:
db132 - Primary database
db131 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
ORA-16597: Data Guard broker detects two or more primary databases
ORA-16625: cannot reach database "db132"
DGM-17017: unable to determine configuration status
DB132:
DGMGRL> show configuration;
Configuration - dg_test11
Protection Mode: MaxPerformance
Databases:
db131 - Primary database
db132 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
ORA-16623: database detected role change
ORA-16625: cannot reach database "db131"
DGM-17017: unable to determine configuration status
数据库实际的情况是这样的:
DB131:
SQL> select database_role,db_unique_name,open_mode,protection_mode,protection
DATABASE_ROLE DB_UNIQUE_NAME OPEN_MODE
---------------- ------------------------------ --------------------
PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS
-------------------- -------------------- --------------------
PHYSICAL STANDBY db131 READ ONLY WITH APPLY
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE NOT ALLOWED
DB132:
SQL> select database_role,db_unique_name,open_mode,protection_mode,protection_level,switchover_status from v$database;
DATABASE_ROLE DB_UNIQUE_NAME OPEN_MODE
---------------- ------------------------------ --------------------
PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS
-------------------- -------------------- --------------------
PRIMARY db132 READ WRITE
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE TO STANDBY
试着disable database,失败。
DGMGRL> disable database db131
Error: ORA-16623: database detected role change
Error: ORA-16625: cannot reach database "db131"
Failed.
DGMGRL> disable database db132
Error: ORA-16623: database detected role change
Error: ORA-16625: cannot reach database "db131"
Failed.
只能暴力删除了,手动删除主库的dg broker配置的原文件,文件存放的目标可以通过show parameter dg_broker来查看。主备都需要
[oracle@qht131 dbs]$ mv dr1db131.dat dr1db131.dat_bak
[oracle@qht131 dbs]$ mv dr2db131.dat dr2db131.dat_bak
将dg_broker_start关闭后重新开启,主备都需要
SQL> alter system set dg_broker_start=false scope=both;
System altered.
SQL> alter system set dg_broker_start=true scope=both;
System altered.
这时再看dg broker的配置信息:
DGMGRL> show configuration;
ORA-16532: Data Guard broker configuration does not exist
根据目前 主从库的实际情况重新建立dg broker的配置,主库是db132,从库是db131:
DGMGRL> create configuration dg_test11 as primary database is db132 connect identifier is orcl132;
Configuration "dg_test11" created with primary database "db132"
DGMGRL> add database db131 as connect identifier is orcl131 maintained as physical;
Database "db131" added
DGMGRL> show configuration;
Configuration - dg_test11
Protection Mode: MaxPerformance
Databases:
db132 - Primary database
db131 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
状态是DISABLED,需要enable一下:
DGMGRL> enable configuration;
Enabled.
DGMGRL> show configuration;
Configuration - dg_test11
Protection Mode: MaxPerformance
Databases:
db132 - Primary database
db131 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
试着进行一次switchover:
DGMGRL> switchover to db131
Performing switchover NOW, please wait...
New primary database "db131" is opening...
Operation requires shutdown of instance "orcl" on database "db132"
Shutting down instance "orcl"...
ORA-01031: insufficient privileges
Warning: You are no longer connected to ORACLE.
Please complete the following steps to finish switchover:
shut down instance "orcl" of database "db132"
start up instance "orcl" of database "db132"
重启一下db132后一切正常了。
不过不太清楚这样强制删除dg broker配置对数据库有没有什么影响。