Switchover
Switchover: The main library and standby data synchronization under normal conditions, mainly for
Primary and standby maintenance, switch drills, etc.;
Failover
Switch: The main library and the standby in the data is not synchronized in the case of forced switchover, mainly with
Yupicu in the case of downtime, failure to switch;
One, switchover switch
The main library and the repository data are synchronized and run normally, and the roles of the main library and the standby library are exchanged;
Before switching, be sure to check whether the current master and standby archives are synchronized, confirm the synchronization and then perform the switchover
Switchover switching the main library operation
1th Step, Main library stop monitoring
Lsnrctl stop
(In theory, there is no need to stop the main library to listen, but in fact, if the database is busy when switching, there are a large number of session connection operation database, in the execution of switching operations need to wait for Oracle to perform session shutdown, sometimes very slow, it is recommended to stop listening directly, stop, You can also check Ps-ef | grep "Local=no", view done, Local=no is the client connection process, and kill-9 kill these non-freed connections, and then perform the following switch)
Ps-ef | grep "Local=no" | Grep-v grep | awk ' {print $} ' | Xargs kill-9
2nd step, Main Library execution switch
Main Library Status Role confirmation
Select Switchover_status from V$database;
There are two types of query results:
First case
Sql> select Switchover_status from V$database;
Switchover_status
--------------------
SESSIONS ACTIVE
If the query results are sessions ACTIVE: perform the following:
Sql>alter database commit to switchover to physical standby W
ith session shutdown;
The second case
Sql> select Switchover_status from V$database;
Switchover_status
--------------------
To STANDBY
If the query results are: To STANDBY, perform the following:
Sql>alter database commit to switchover to physical standby;
3rd step, close the main library
Sql>shutdown Immediate
Ora-01507:database not mounted
ORACLE instance shut down.
4th step, Main Library boot to Mount state
Sql>startup Mount
ORACLE instance started.
Total System Global area 9646899200 bytes
Fixed Size 2087000 bytes
Variable Size 822085544 bytes
Database buffers 8808038400 bytes
Redo buffers 14688256 bytes
Database mounted.
The 5th step, the main library determines the state after switching
Sql>select open_mode,database_role,switchover_status from V$database;
Open_mode Database_role Switchover_status
---------- ---------------- -------------------- ------------
------------------------
Mounted physical STANDBY SESSIONS ACTIVE
The database role becomes the physical STANDBY (physical standby), which completes the role transformation of the main library;
6th step, Main Library start monitoring
Lsnrctl start
Switchover switching the Standby library operation
Standby library execution switch to Primary library mode
1th step, Standby status role confirmation
Sql>select switchover_status from V$database;
First case
Sql> select Switchover_status from V$database;
Switchover_status
--------------------
To PRIMARY
If the status is to PRIMARY, the following statement is executed:
Sql>alter database commit to switchover to primary;
The second case
Sql> select Switchover_status from V$database;
Switchover_status
---------------------------------
SESSIONS ACTIVE
If the status is sessions active, execute the following statement:
ALTER DATABASE commit to switchover-primary with session shutdown;
2nd step, Standby library open
ALTER DATABASE open;
3rd step, Standby status role confirmation
Sql>select open_mode,database_role,switchover_status from V$database;
Open_mode Database_role Switchover_status
---------- ---------------- -------------------- ------------
--------------------------
READ WRITE PRIMARY
SESSIONS ACTIVE
4th, Master Library start synchronization
Execute on the primary repository:
Sql>alter DATABASE OPEN;
Sql>alter database RECOVER MANAGED STANDBY database USING current LOGFILE DISCONNECT from SESSION;
Switchover switch is complete;
This article is from the "ermei22" blog, make sure to keep this source http://ermei22.blog.51cto.com/9186534/1870113
Oracle DG Library Switchover primary and standby switching