Oracle 10 Gb physical master database and slave database:
Switchover: switches between the master database and the slave database under normal synchronization conditions. It is mainly used for Master/Slave maintenance and switchover drills;
Failover switchover: Forced failover between the master and slave databases when data is not synchronized, mainly used for failover when the master database goes down or fails;
1. switchover Switching
Data is synchronized between the master database and the slave database and runs normally. Roles of the master database and the slave database are exchanged;
Before switching, check whether the archive of the current master database and slave database is synchronized. After confirming the synchronization, perform the switchover.
Switchover
Step 3: stop listening to the master database
Lsnrctl stop
(Theoretically, the master database does not need to be stopped, but in fact, if the database is busy during the switchover and there are a large number of sessions connected to the database, you need to wait for oracle to execute session shutdown when performing the switchover operation, sometimes it will be slow. We recommend that you stop the listener directly. After stopping the listener, you can check ps-ef | grep "LOCAL = NO". LOCAL = NO is the client connection process, kill-9 and kill the unreleased connections, and then perform the following switchover)
Step 2: Switch the master database
Master database status role confirmation
Select switchover_status from v $ database;
The query results can be divided into two situations:
First case
SQL> select switchover_status from v $ database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
If the query result is sessions active: execute the following:
SQL> alter database commit to switchover to physical standby with session shutdown;
Case 2
SQL> select switchover_status from v $ database;
SWITCHOVER_STATUS
--------------------
TO STANDBY
If the query result is: to standby, execute the following:
SQL> alter database commit to switchover to physical standby;
Step 3: Close the master database
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
Step 2: The master database is started to the mount status
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.
Step 2: The master database determines the status after switching
SQL> select open_mode, database_role, switchover_status from v $ database;
OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS
----------------------------------------------------------------------------------
MOUNTED PHYSICAL STANDBY SESSIONS ACTIVE
Database role changed to physical standby (physical standby database)
Role conversion of the master database is completed;
Step 2: Start listening for the master database
Lsnrctl start
Switchover switch slave database operation
Slave database switch to master database mode
Step 2. confirm the role of the standby database status
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, execute the following statement:
SQL> alter database commit to switchover to primary;
Case 2
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 to primary with session shutdown;
Step 2: Open the standby Database
Alter database open;
Step 2. confirm the role of the standby database status
SQL> select open_mode, database_role, switchover_status from v $ database;
OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS
------------------------------------------------------------------------------------
READ WRITE PRIMARY SESSIONS ACTIVE
Step 2: Start synchronization for the original master database
Run the following command on the original master database:
Alter database recover managed standby database using current logfile disconnect from session;
Switchover Switch complete;