db2 main library:
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE
db1 as standby
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY
db2 simulations of closed main library
SQL> shu abort
ORACLE instance shut down.
View the status of db1 again:
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE
IV: automatic switching process:
4.1: The test takes about 10 seconds observer to detect failure of the main library!
DGMGRL> start observer;
Observer started
20:15:59.44 Thursday, July 04, 2019
Initiating Fast-Start Failover to database "db2"...
Performing failover NOW, please wait...
Failover succeeded, new primary is "db2"
20:16:01.77 Thursday, July 04, 2019
Process 4.2 failover and manual failover as whether automated failver, or manually execute FAILOVER TO, are executed with the command-line failover command the following two commands:
alter database recover managed standby database finish force; --- stop rfs process
alter database commit to switchover to primary;---由open到mount
alter database open; ---- read write Open
When failover occurs, the following can be seen through such a process is indeed
1) begin state:. Rfs and mrp process are normal
SQL> select process,status ,sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
--------- ------------ ----------
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CLOSING 14
RFS IDLE 0
RFS IDLE 15
RFS IDLE 0
MRP0 APPLYING_LOG 15
8 rows selected.
2) .rsf process disappears
SQL> select process,status ,sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
--------- ------------ ----------
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CLOSING 14
MRP0 APPLYING_LOG 15
3) The database becomes mounted
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY MOUNTED
4) database becomes open write a
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE
4.3: manually perform failover;
DGMGRL> help failover
Changes a standby database to be the primary database
Syntax:
FAILOVER TO <standby database name> [IMMEDIATE];
When the failover occurs:
View configuration states: the original discovery of the main library needs to be reinstated, you need to use the command REINSTATE under repair, in order to become the new main library from the library!
DGMGRL> show configuration
Configuration - dbha_c
Protection Mode: MaxPerformance
Databases:
db2 - Primary database
Warning: ORA-16829: fast-start failover configuration is lagging
db1 - (*) Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated
Fast-Start Failover: ENABLED
Configuration Status:
WARNING
First, start the original primary database to mount state:
SQL> startup mount
DGMGRL> help reinstate
Changes a database marked for reinstatement into a viable standby
Syntax:
REINSTATE DATABASE <database name>;
DGMGRL> REINSTATE DATABASE db1
Reinstating database "db1", please wait...
Reinstatement of database "db1" succeeded
View original master library again:
SQL> select process,status ,sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
--------- ------------ ----------
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CLOSING 5
RFS IDLE 0
RFS IDLE 0
RFS IDLE 0
RFS IDLE 6
MRP0 APPLYING_LOG 6
It is actually reinstate the implementation of the following procedure:
If you want to convert the original main library for the new library equipment
Requirements former main library must be opened flashbackup database functionality, after failover,
1. View from the library becomes the primary failover time scn number.
SQL> select STANDBY_BECAME_PRIMARY_SCN from v$database;
STANDBY_BECAME_PRIMARY_SCN
--------------------------
15468
2. Flash back to the original primary database to the scn No. 15468;
SQL>FLASHBACK DATABASE TO SCN 15468 ;
Database altered.
3. In the original primary database to perform a handover:
SQL> alter database convert to physical standby ;
Database altered.
4. Close the original primary libraries
SQL>shu immediate
5. Open the original master library to mount state,
SQL>startup mount;
6. On the new primary database archive the newly generated log to a new library prepared
SQL>alter system archive log current;
7. Open mrp-process application log, replay changes
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
5. Check status:
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CLOSING
ARCH CONNECTED
ARCH CONNECTED
ARCH CLOSING
MRP0 APPLYING_LOG
RFS IDLE
RFS IDLE
RFS IDLE
At this point the original main library has become the new master of the standby.