Oracle 11GR2 Dataguard Switchover FAILOVER

Source: Internet
Author: User
Tags commit failover prepare sessions switches


1. Switch: User actively switch;
2. Failover: Main Library failure, forced to switch;



Switchover: General switchover switch are planned to switch, characterized by switching, will not lose any data, and this process is reversible, the entire dataguard environment will not be destroyed, All physical and logical standby in the original Dataguard environment can continue to work.
Before you make a physical standby switch for Dataguard, you need to be aware of:
1, confirm the main library and from the Library network connectivity unobstructed;
2. Confirm that no active session is connected to the database;
3, the primary database is in the open state, the standby database is in Mount State;
4, to ensure that the standby database in Archivelog mode;
5, if set the Redo application delay, then this setting is removed;
6, to ensure the configuration of the main library and from the library initialization parameters, so that after the handover, the dataguard mechanism can run smoothly.
Switch switching process: Piontes Library



Main Library:
because the main library is open and accessible, the Switch_status is session active in the V$database view, and the primary switch to standby requires the database to be open, so when you perform a toggle command, With the session shutdown option.
After the switch command is finished, close the database, restart the database to mount status, wait for log transfer, and open the log application.
View alert log to see what the main library does: the main library disconnects all sessions (uncommitted transactions are rolled back), backs up control files, switches logs and archives, transmits logs to the standby, gives the repository a End-of-redo signal, switches to standby, Reboot to mount.
To view the switchover status:


The code is as follows
Sql> select Database_role,switchover_status from V$database;


Attached: A:switchover_status appeared session Active/not allowed
When session active occurs, there is also an active session


The code is as follows
Sql> ALTER DATABASE commit to switchover to physical standby with session shutdown;
sql> shutdown immediate;
sql> startup Nomount;
Sql> ALTER DATABASE mount standby database;


Prepare library:
Confirm that you can switch to the main library, and if switchover_status is recovery needed or switchover latent, you need to apply all the archive logs to switch. In the case of sessions active, bring with the session shutdown option. After you apply all the logs, you can switch to primary, and then open the database.



View Alert.log can see what the backup did: Close the arch process, receive the main library log, receive the main library End-of-redo signal, apply all the logs, empty the online redo log to open the database, switch to primary, open the database.


  code is as follows
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 D Isconnect from the session;
Database altered.
Sql> Select Database_role,switchover_status from V$database;
Database_role switchover_status
—————-—————— –
Physical standbyto PRIMARY
Sql> alter DATABASE commit t O Switchover to primary with session shutdown;
Database altered.
Sql> shutdown Immediate;
Sql> startup;


The above process, because the main library disconnect all sessions and archive, transfer logs to the standby, to send the end-ofredo signal, so normal swithch, is not lost data.
After the handover can be archived in the main library, verify whether the switch is successful, the standby library can normally receive logs.



Open log Application: (Main Library-Yuanbeku)


The code is as follows
sql> ALTER DATABASE recover managed standby database using current logfile disconnect from session;





FailOver: When the main library is lost and cannot be used, the switch at this point is FailOver, and if the protection mode is the maximum performance mode, it is possible to lose data.
Prepare the library end:
If it is the maximum protection and maximum availability mode, you can perform a failover switch directly on the standby side of the library. In the case of maximum performance mode, in order to minimize data loss, you need to check whether the main library has logs that are not transferred to the standby, and manually transfer the repository for registration and recovery. Note in the RAC Environment, the archive log is threaded.



1. Stop Log Application


The code is as follows
ALTER DATABASE recover managed standby database cancel;


2. Turn off standby log transmissions


The code is as follows
ALTER DATABASE recover managed standby database finish force;


3. Switch to Primary


The code is as follows
ALTER DATABASE commit to switchover to primary with session shutdown;


To do this step, if there is gap, it will be reported Ora-16139:switchover:media recovery Required–standby not in limbo error.
When you do the test, if you start the main library and then prepare the library, and do not wait for the backup of the relevant log transmission completed, this problem will occur. You need to force a switch at this time


The code is as follows
ALTER DATABASE activate physical standby database;


4. Restart database to open state


The code is as follows
[Oracle@testdb dev01]$ SCP * ORACLE@192.168.0.8:/U01/ARCHIVE/DEV01DG


There are two ways to register an archive log, but it is easier to use Rman and register multiple at a time.


/tr>
  code is as follows
rman> Catalog start with '/u01/archive/dev01′;
Sys@dev01dg>alter Database Register logfile '/u01/archive/dev01dg/arch_e8fe6364_1_712757927_460.dbf '; The
Apply archive log also has two methods.
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/archi VE/DEV01DG/ARCH_E8FE6364_1_712757927_461.DBF
Ora-00280:change 2863819 for thread 1 are in sequence #461


After manually apply all the log, you can failover switch to the primary, but note that, because the library does not receive the main library of the End-of-redo signal, so direct conversion will be an error, request media recovery, at this time need to submit a command to tell the library, Log restore has finish, need to make failover switch, pay attention to switch when do not have the finish option, otherwise it will become failover.


The code is as follows
Sys@dev01dg> ALTER DATABASE commit to switchover to primary with the session shutdown;
ALTER DATABASE commit to switchover to primary with the 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 the 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


When the failover is finished, the database is actually opened in resetlogs mode, and if log_archive_format= ' arch_%d_%t_%r_%s.dbf ', you can see that the file name of the archive log will have a new resetlogs ID and Sequence number to differentiate it from the original archive log.



Supplemental 11g Official document processing order and Operation statement
1, the main library switch


The code is as follows
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, Standby library switching


The code is as follows
SELECT switchover_status from V$database;
ALTER DATABASE COMMIT to switchover to PRIMARY with session SHUTDOWN;
ALTER DATABASE OPEN;


3. Open Application (new reserve-original repository)


  code is as follows
alter DATABASE RECOVER MANAGED STANDBY DATABASE USING current LOGFILE DISCONNECT from session;
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.