特别强调:在使用dg broker在执行failover to xxx需要确认一下 主备库是否开启flashback,如果没有开启,需要执行,否则会报错并且库基本上需要重新手工同步了。
alter database flashback on; --开启数据库一级的flashback功能
[oracle@node1 ~]$ dgmgrl
DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
Copyright (c) 2000, 2013, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle@orcl
Connected as SYSDBA.
DGMGRL> show configuration
Configuration - dg
Protection Mode: MaxPerformance
Members:
orcl - Primary database
orcl2 - Physical standby database (disabled)
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 43 seconds ago)
DGMGRL> w;
Unrecognized command "w", try "help"
DGMGRL> enable database orcl2
Enabled.
DGMGRL> show configuration
Configuration - dg
Protection Mode: MaxPerformance
Members:
orcl - Primary database
orcl2 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 4 seconds ago)
DGMGRL> failover to orcl2
Performing failover NOW, please wait...
Error: ORA-16600: not connected to target standby database for failover
Failed.
Unable to failover
DGMGRL> exit
[oracle@node1 ~]$ dgmgrl
DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production
Copyright (c) 2000, 2013, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle@orcl2
Connected as SYSDBA.
DGMGRL> failover to orcl2
Performing failover NOW, please wait...
Failover succeeded, new primary is "orcl2"
DGMGRL> show configuration
Configuration - dg
Protection Mode: MaxPerformance
Members:
orcl2 - Primary database
orcl - Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 81 seconds ago)
DGMGRL> connect sys/oracle@orcl
Connected as SYSDBA.
DGMGRL> reinstate database orcl
ORA-16795: the standby database needs to be re-created
Configuration details cannot be determined by DGMGRL
DGMGRL> connect sys/oracle@orcl2
Connected as SYSDBA.
DGMGRL> reinstate database orcl
Reinstating database "orcl", please wait...
Operation requires shut down of instance "orcl" on database "orcl"
Shutting down instance "orcl"...
ORACLE instance shut down.
Operation requires start up of instance "orcl" on database "orcl"
Starting instance "orcl"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "orcl" ...
Reinstatement of database "orcl" succeeded
DGMGRL> show configuration
Configuration - dg
Protection Mode: MaxPerformance
Members:
orcl2 - Primary database
orcl - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 20 seconds ago)
DGMGRL> switchover to orcl
Performing switchover NOW, please wait...
Operation requires a connection to instance "orcl" on database "orcl"
Connecting to instance "orcl"...
Connected as SYSDBA.
New primary database "orcl" is opening...
Operation requires start up of instance "orcl2" on database "orcl2"
Starting instance "orcl2"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "orcl"
DGMGRL>