Oracle Data Guard role conversion

Source: Internet
Author: User

Lab environment: OEL + Oracle11.2.0.3 + physical standby

As we all know, Data Guard is already the mainstream disaster tolerance solution of today's standards. Due to its strong adaptability to the network, it can adopt synchronous real-time transmission methods and asynchronous delay transmission methods, it can even become a remote disaster recovery solution. Regardless of the purpose, the DG will inevitably require role conversion, namely switching the standby database to the primary database. role conversion can be divided into switchover and failover; the two differences are compared from three perspectives:

(1) different application scenarios: Switchover is used for scheduled Switchover, usually for normal tasks such as system upgrades and data migration. Failover is used for unexpected emergencies, for example, abnormal power loss and natural disasters.

(2) different degrees of data loss: Switchover will not lose data, and Failover usually means that some data is lost.

(3) different solutions: After Switchover, the crash uard environment will not be damaged, and any system with the Primary and Standby roles will exist. However, after Failover, the deployment uard environment will be damaged and must be rebuilt.

1. Switchover

Because Switchover is manually triggered by DBAs, Switchover's steps are standardized. The Switchover process begins with the Primary Database and ends with the Standby Database.

The steps for Switchover are as follows:

1. Check the database switchover status on the master database.

SQL> select switchover_status from v $ database;

SWITCHOVER_STATUS: to standby indicates that the switchover is normal.

If the value of SWITCHOVER_STATUS is sessions active, the current session is ACTIVE.

 

2. The master database is switched normally.

If the value of SWITCHOVER_STATUS is to standby:

SQL> alter database commit to switchover to physical standby;
Database altered.

If the value of SWITCHOVER_STATUS is sessions active:

SQL> alter database commit to switchover to physical standby with session shutdown;
Database altered.

When Primary Database receives this command, the following events occur:

(1) After the command is executed, no Redo will be generated on the master database. All DML-related Cursor will be invalid and the user will no longer be able to execute transactions.

(2) The current log of each log Thread is archived, and a special switch standard EOR (End of Redo) is recorded in the new log header of each Thread next, and then archived again, the result is that the EOR is sent to all Standby databases, and the Primary Database is converted to Standby.

(3) On this old Primary Database, the MRP (Managed Recovery Process) Process will automatically start and apply the last archived log, that is, the EOR log, once this EOR application is complete, the Database will be Dismounted and must be started into a Standby Database.

3. Restart the previous master database

SQL> SHUTDOWN IMMEDIATE; (11g sometimes requires shutdown abort, or an error is reported)

SQL> startup mount;

4 at this time, the status can be switched to the backup database for verification in the backup database.

SQL> select switchover_status from v $ database;

SWITCHOVER_STATUS

-----------------

TO_PRIMARY

1 row selected

5. Convert the target slave database to the master database

If the value of SWITCHOVER_STATUS is to standby, then:

SQL> alter database commit to switchover to primary;
Database altered.

If the value of SWITCHOVER_STATUS is sessions active, then:

SQL> alter database commit to switchover to primary with session shutdown;
Database altered.

After executing this command, the control file of the Standby Database is also converted from the Standby control file to the standard control file. Then, the database can open the Database and open it into a business database.

6. Restart the target slave database.

SQL> shutdown immediate;

SQL> startup;

7. The previous master database started the log Transfer Process

SQL> alter database recover managed standby database disconnect;

8. Check the role status of the Master/Slave database:

Select switchover_status, database_role from v $ database;

So far, a complete Switchover completes the role swap and can be used normally.

  • 1
  • 2
  • Next Page

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.