“This is the 21st day of my participation in the Gwen Challenge in November. See details: The Last Gwen Challenge in 2021”

Environment to prepare

  The host name ip DB Version db_name db_unique_name
The main library orcl 192.168.56.120 11.2.0.4 orcl orcl
For the library orcl_stby 192.168.56.121 11.2.0.4 orcl orcl_stby

Notes:

1. Db_unique_name The active and standby databases must be different.

2. The db_name must be the same as that of the active and standby databases.

3. The DB versions of the active and standby databases must be consistent.

Set up ADG in advance, please refer to:

ADG single instance series setup (RMAN backup recovery)

Active Database Duplicate Using Image Copies

ADG Single Instance Build series (DBCA)

A, Enable the Broker

--both databases (primary and standby)

ALTER SYSTEM SET dg_broker_start=true;
Copy the code

Register server with the Broker

dgmgrl sys/oracle@orcl

##pri is the configuration name, optional
The first orCL is db_unique_name
## The second orCL is TNSNAME
CREATE CONFIGURATION pri AS PRIMARY DATABASE IS orcl CONNECT IDENTIFIER IS orcl;

The first orcl_stby is db_unique_name
## The second orcl_stby is TNSNAME
ADD DATABASE orcl_stby AS CONNECT IDENTIFIER IS orcl_stby MAINTAINED AS PHYSICAL;

ENABLE CONFIGURATION;
Copy the code

Iii. Check the configuration and database

SHOW CONFIGURATION;

SHOW DATABASE orcl;

SHOW DATABASE orcl_stby;
Copy the code

Fourth, the Database Switchover

Configure Listener Both Primary and Standby

vi $TNS_AMDIN/listener.ora

# # is GLOBAL_DBNAME db_unique_name + DGMGRL
##primary add(SID_DESC = (GLOBAL_DBNAME = orcl_DGMGRL) (ORACLE_HOME = / u01 / app/oracle/product / 11.2.0 / db) (SID_NAME = former))##standby add(SID_DESC = (GLOBAL_DBNAME = orcl_stby_DGMGRL) (ORACLE_HOME = / u01 / app/oracle/product / 11.2.0 / db) (SID_NAME = former))Copy the code

1. A SWITCHOVER error is reported: ora-12514 if a DGMGRL listener is not configured

SWITCHOVER TO orcl_stby;
Copy the code

Master cut:

For cutting the main:

Fifth, the Database Failover

If the FLASHBACK is enabled for the primary database in advance, Failover can be switched back to the standby database to prevent the primary database from being disabled.

ALTER DATABASE FLASHBACK ON;

ALTER SYSTEM SET db_recovery_file_dest_size=5G;
Copy the code

# standby DGMGRL operation
FAILOVER TO orcl_stby IMMEDIATE;
Copy the code

Switching from the original primary database to the standby database:

# standby DGMGRL operation
REINSTATE DATABASE orcl;
Copy the code

Sixth, the Snapshot Standby

Snapshot Standby Database is a new feature of ORACLE 11g. Allows the Physical Standby to use Read Write mode for a short period of time. Must be ADG support.

** Note: ** Once the snapshot standby is activated beyond the primary’s maximum load time, another local update operation will generate additional exceptions.

DGMGRL ()

CONVERT DATABASE orcl_stby TO SNAPSHOT STANDBY;
Copy the code

Switching back to physical standby:

The main library DGMGRL is executed

CONVERT DATABASE orcl_stby TO PHYSICAL STANDBY;
Copy the code