An oracle 11GR2 javasuard switchover failover article, hoping to help you.
1. switch: the user actively switches;
2. failover: the master database fails and the switchover is forced;
Switchover, all physical and logical standby operations in the dataguard environment can continue.
Note the following before performing the physical standby switch of the volume uard:
1. confirm that the network connection between the master database and slave database is smooth;
2. confirm that no active sessions are connected to the database;
3. The primary database is in the open state, and the standby database is in the mount state;
4. Ensure that the standby database is in archivelog mode;
5. If the redo application latency is set, remove this setting;
6. Ensure that the initialization parameters of the master database and slave database are configured so that the dataguard mechanism can run smoothly after the switchover is complete.
Switch switching process: master database and slave Database
Master database:
Because the master database is open and accessed, switch_status in the v $ database view is session active, and switching from primary to standby requires that the database be open. Therefore, when you execute the switch command, with the with session shutdown option.
After the switchover command is executed, shut down the database, restart the database to the mount status, wait for log transmission, and enable the log application.
View the alert log to see what actions the master database has done: disconnect all sessions from the master database (uncommitted transactions will be rolled back), back up control files, switch logs and archive, and transmit logs to the slave database, give the slave database an End-Of-REDO signal, switch to standby, and restart to mount.
View the switchover status:
The Code is as follows: |
Copy code |
SQL> select database_role, switchover_status from v $ database;
|
Appendix: A: switchover_status displays session active/not allowed
When a session is active, it indicates that there are still active sessions.
The Code is as follows: |
Copy code |
SQL> alter database commit to switchover to physical standby with session shutdown; SQL> shutdown immediate; SQL> startup nomount; SQL> alter database mount standby database; |
Slave database:
Check whether it can be switched to the master database. If switchover_status is recovery needed or switchover latent, you need to apply all the archived logs before switching. If it is sessions active, the with session shutdown option is included. After applying all the logs, you can switch to primary and open the database.
View alert. log shows the actions performed by the slave Database: Shut down the arch process, receive logs from the master database, receive the End-Of-REDO signal from the master database, and apply all logs, clear the online redo log to open the database, switch to primary, and open the database.
The Code is as follows: |
Copy code |
SQL> select database_role, switchover_status from v $ database; SQL> alter database commit to switchover to primary with session shutdown; ERROR at line 1: ORA-16139: media recovery required SQL> alter database recover managed standby database disconnect from session; Database altered. SQL> select database_role, switchover_status from v $ database; DATABASE_ROLE SWITCHOVER_STATUS ------------- PHYSICAL STANDBYTO PRIMARY SQL> alter database commit to switchover to primary with session shutdown; Database altered. SQL> shutdown immediate; SQL> startup; |
In the above process, because the master database disconnects all sessions and archives the logs, transmits the logs to the slave database, and sends the signal to the slave Database end-ofredo, data will not be lost during normal swithch.
After the switchover, You can archive the file in the master database to verify whether the switchover is successful and whether the slave database can receive logs normally.
Enable log application: (master database-original standby database)
The Code is as follows: |
Copy code |
SQL> alter database recover managed standby database using current logfile disconnect from session; |
FailOver: when the master database fails and cannot be used, the switchover is failover. If the protection mode is the maximum performance mode, data may be lost.
Slave database:
If the mode is the maximum protection and maximum availability, you can directly perform the failover switch on the slave database. For the maximum performance mode, to minimize data loss, you need to check whether logs in the master database are not transmitted to the slave database, and manually transfer the slave database for registration and recovery. Note that archive logs are divided into threads in the RAC environment.
1. Stop the log application
The Code is as follows: |
Copy code |
Alter database recover managed standby database cancel;
|
2. Disable standby log Transmission
The Code is as follows: |
Copy code |
Alter database recover managed standby database finish force;
|
3. Switch to primary
The Code is as follows: |
Copy code |
Alter database commit to switchover to primary with session shutdown;
|
If a gap exists during this step, the ORA-16139: Switchover: Media recovery required-standby not in limbo error is reported.
During the test, this problem occurs if the master database is started and then the slave database is not waiting for the log transmission of the slave database to complete. Force Switch
The Code is as follows: |
Copy code |
Alter database activate physical standby database;
|
4. Restart the database to the open state.
The Code is as follows: |
Copy code |
[Oracle @ testdb dev01] $ scp * oracle@192.168.0.8:/u01/archive/dev01dg
|
You can register archive logs in either of the following two methods. It is simpler, of course, to register multiple logs at a time.
The Code is as follows: |
Copy code |
RMAN> catalog start with '/u01/archive/dev0 ′; SYS @ dev01dg> alter database register logfile '/u01/archive/dev01dg/arch_e8fe6364_109712757927_460.dbf '; You can use either of the following methods to apply logs. SYS @ dev01dg> alter database recover managed standby database disconnect from session; Database altered. SYS @ dev01dg> recover standby database; ORA-00279: change 2863819 generated at 03/20/2010 21:58:17 needed for thread 1 ORA-00289: suggestion:/u01/archive/dev01dg/arch_e8fe6364_410712757927_461.dbf ORA-00280: change 2863819 for thread 1 is in sequence #461
|
After manually applying all the logs, you can switch the failover to primary. However, note that the slave database does not receive the end-of-redo signal from the master database, therefore, an error is reported during direct conversion and the media recovery is required. In this case, you need to submit a command to inform the slave database that the log recovery has been completed and failover switching is required. Note that the switch must not contain the finish option, otherwise it will become a failover.
The Code is as follows: |
Copy code |
SYS @ dev01dg> alter database commit to switchover to primary with session shutdown; Alter database commit to switchover to primary with session shutdown * ERROR at line 1: ORA-16139: media recovery required SYS @ dev01dg> select database_role, switchover_status from v $ database; DATABASE_ROLE SWITCHOVER_STATUS ------------- PHYSICAL STANDBYNOT ALLOWED SYS @ dev01dg> alter database recover managed standby databasefinish [force]; Database altered. SYS @ dev01dg> select database_role, switchover_status from v $ database; DATABASE_ROLE SWITCHOVER_STATUS ------------- PHYSICAL STANDBYTO PRIMARY SYS @ dev01dg> alter database commit to switchover to primary with session shutdown; Database altered. SYS @ dev01dg> alter database open; Database altered. SYS @ dev01dg> select database_role, switchover_status from v $ database; DATABASE_ROLE SWITCHOVER_STATUS ------------- PRIMARY SESSIONS ACTIVE
|
After failover is complete, the database is actually opened in resetlogs mode. If log_archive_format = 'arch _ % d _ % t _ % r _ % s. dbf', you can see that the file name of the archive log has a new resetlogs ID and sequence number, which are distinguished from the original archive log.
Supplement the processing sequence and operation statements of the 11g Official Documents
1. master database Switching
The Code is as follows: |
Copy code |
SELECT SWITCHOVER_STATUS from v $ DATABASE; Alter database commit to switchover to physical standby with session shutdown; Shutdown immediate; Startup nomount; Alter database mount standby database;
|
2. Slave database Switching
The Code is as follows: |
Copy code |
SELECT SWITCHOVER_STATUS from v $ DATABASE; Alter database commit to switchover to primary with session shutdown; Alter database open;
|
3. Enable the application (new slave database-original master database)
The Code is as follows: |
Copy code |
Alter database recover managed standby database using current logfile disconnect from session;
|