Oracle physical standby role conversion

A. DataGuard Profile

  Oracle DataGuard; referred to as DG. It is a Primary Database (primary library) and one or more Standby Database (Library Preparation) composition. For Oracle; itself does not improve performance. To protect data by data redundancy. Primary Database provided by external services; user operates the operation on Primary Database; Redo Log database operation thereof or to the Standby Database Archive log transmitted through the network. Standby Database in redo logs. In order to achieve Primary Database Standby Database and data synchronization.

Chart as follows:

 

 

Oracle DataGuard in Standby library in two ways: physical and logical Standby Standby.

  • Logical Standby after receiving convert it into SQL statements, execute SQL statements on the Standby database synchronization, this approach is called SQL Apply.
  • After receiving the physical Standby REDO Primary data generated by the database, so as to synchronize media recovery, this approach is also called Redo Apply.

The present embodiment uses the physical architecture Standby; Two roles in Oracle DataGuard: Primary and Standby

Two, Oracle DataGuard roles and role reversal

2.1, Oracle DataGuard two roles

  • Primary role: the corresponding database-based repository. Foreign can provide read and write operations; and some database maintenance operations are also on the main library.
  • Standby roles: to prepare the corresponding database library. Provide external read only. Representative and database backup of the database.

2.2, role reversal

Foreign database to provide high availability; failure of the main library; library equipment can improve the main library to provide services; does not affect the normal operation of the business. This operation needs to be done is a role reversal.

Role reversal, there are two different types of operations: switchover and failover. The former is a lossless handover without loss of data. The latter data may be lost. And after the handover original Primary databases are no longer part of the DataGuard. It is also possible to provide services; in other database called "split brain."

2.2.1、switchover

Which is the primary database and a standby database conversion, switchover to ensure no loss of data, which is typically done when the system planned maintenance.

scenes to be used

  • Disaster drills planned switch, such as availability, client connectivity test disaster recovery site to ensure that the main library major accident occurs, you can switch to the normal operation by the library.
  • Maintain and upgrade the main library for a long time, such as OS upgrades, DB rolling upgrade, replace the memory, the replacement of OS hardware devices.
  • Switching risk, generally do not switch.

2.2.2、failover

When the primary database is inactive, Failover Standby database can be converted to a master database role, Failover may result in data loss situation occurs. Failover used only in case of failure in the master data.

Third, preparation

  • Check the database initialization parameter file, mainly Recognizing the role of the database to be converted, the relevant initialization parameters different roles are configured correctly.
  • Check the server is about to become physical Standby database Primary whether the archive mode
  • Temporary Files check whether the physical Standby database exists, and temporary files that match Primary database
  • Selecting a most suitable physical Standby converted to Primary. Such as inspection database IO / CPU / memory. After ensure the transition to provide services.

Fourth, the steps

3.1, the implementation of switchover

Primary end database from the original start operation; to operate the new Primary database side end

3.1.1, Primary node

Query V $ DATABASE view SWITCHOVER_STATUS column.

  • Check whether to support switchover operation
SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
------------------------------------------------------------
TO STANDBY
  • The results for the TO STANDBY; it means Primary database supports conversion into Standby role.
  • The result is SESSIONS ACTIVE; description of the current session in connection Primary database there. This represents the termination can not be converted; oracle need to close all client connections. The need to inform in advance the developer to terminate client connections. You can also use command to force termination
ps -ef | grep oracleorcl | awk '{system("kill -9 " $2)}'
  • Start switchover

Convert primary database to standby role

ALTER  Database  the commit  to switchover to PHYSICAL STANDBY;
 - pre-step process can be used in connection with a user 
ALTER  Database  the commit  to switchover to PHYSICAL STANDBY with the session the shutdown ;

Execute the command. The original primary database will revert to standby database.

Restart the original primary database to mount state

shutdown immediate;
startup mount;

3.1.2, standby node

Query V $ DATABASE view SWITCHOVER_STATUS column.

  • Check whether to support switchover operation
SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
------------------------------------------------------------
TO PRIMARY
  • The result is TO PRIMARY; indicates standby database supports conversion to the primary role.
  • Result SESSIONS ACTIVE; session connection with a description of the current primary standby database
  • The results for the SWITCHOVER PENDING; description standby database redo the current application does not start. carried out
alter database recover managed standby database using current logfile disconnect from session;
  • switchover
alter database commit to switchover to primary;

Restart the database

The new standby database applications to start redo

alter database recover managed standby database using current logfile disconnect from session;

3.2, perform failover

failover operation; generally indicates primary database paralyzed, at least is a failure. Equivalent to the primary database server hung up. Now we need to upgrade the standby database to take over the service. There may be a loss of data in the process. All recommendations Primary database can be used. Do not perform failover.

3.2.1 to check whether continuous archive log

v $ archive_gap view of the query to be converted standby database; confirm whether continuous archive

select thread#, low_sequence#, high_sequence# from v$archive_gap;

If returned records; Add command data dictionary

alter database register physical logfile 'filesepec1'

3.2.2, start failover

alter database recover managed standbyf database finish force; 

3.2.3, into primary node

alter database commit to switchover to primary

3.2.4, restart the database

Guess you like

Origin www.linuxidc.com/Linux/2019-12/161816.htm