DG's core function is to provide high availability disaster, so the role-switching content described in this section is the most important part of DG. The role switching between DG Master and slave Libraries is divided into the following two kinds:
1) Switchover
Swithchover refers to the master-slave library for role swaps (master Library, reserve library variable main library), usually man-made, planned, such as the use of switchover can reduce the database upgrade downtime, so do not cause data loss.
2) Failover
Failover refers to the main library because the failure can not be recovered in a short time, in order to ensure the availability of data, the repository has to temporarily act as the role of the main library, if the DG Data protection mode is the maximum performance mode, this switch is likely to lead to data loss.
The following shows the switchover and failover of the physical and logical repositories respectively
Switchover and failover of physical repositories
1. Switchover of the physical reserve library
1 confirm that the main library can be switched to a standby library
Sql>select switchover_status from V$database;
Switchover_status
--------------------to
STANDBY
2 Switch the main library into a physical standby library
Sql>alter database commit to switchover to physical standby;
3) Close the main library and reboot to Mount state
Sql>shutdown Abort
Sql>startup Mount
At this point the identity of the main library has changed to become a physical repository.
4 Confirm that the physical repository can be switched to the main library
Sql>select switchover_status from V$database;
Switchover_status
--------------------to
PRIMARY
5 switching the original physical repository to the new main library
Sql>alter database commit to switchover to primary;
Database altered.
Sql>alter database open;
Database altered.
6 Start the log application in the new home library
sql> ALTER database RECOVER MANAGED STANDBY database USING current LOGFILE DISCONNECT from session;
7) Verify
Sql>select database_role from V$database;
Database_role
----------------
physical STANDBY
sql>select database_role from V$database;
Database_role
----------------
PRIMARY
From the above you can see that the original main library has now become physical, the original physical repository into the main library.
Check that the log_archive_dest_n parameters for the new home library are set correctly:
Sql>show parameter log_archive_dest_2
NAME TYPE VALUE
--------------------------------------- --------------------------------------
log_archive_dest_2 string service=o01dms0 ARCH valid_for
=
(online_logfiles,primary_role
) db_unique_name=o01dms0
sql>show parameter Log_archive_dest_ state_2
NAME TYPE VALUE
------------------------------------------------------------------ --
log_archive_dest_state_2 string ENABLE