Get the App
SLTechnology News&Howtos  ›  Database  › 

[Data guard] Switchover handoff

Shulou Source: shulou.com Published: 2022-06-01 05:40:24 10月03日 Update

Verification of switching operation between active and standby libraries 1. Main library switching (machine A)

(1) Check the status of the master library

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS

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

bhtc db READ WRITE PRIMARY TO STANDBY

(2) Main library executes switching command

SQL> alter database commit to switchover to physical standby with session shutdown wait;

Database altered.

(2) Restart the main library role to become a standby library (mount state)

SQL> startup mount;

ORACLE instance started.

Total System Global Area 1.3429E+10 bytes

Fixed Size 2265944 bytes

Variable Size 6878661800 bytes

Database Buffers 6543114240 bytes

Redo Buffers 4612096 bytes

Database mounted.

(4) Check the status of the master library

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS

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

Bhtc db MOUNTED PHYSICAL STANDBY RECOVERY NEEDED

2. Backup library switched to main library (B machine)

(1) Check the stock status

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS

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

bhtcdg MOUNTED PHYSICAL STANDBY TO PRIMARY

(2) Switch the backup library to the main library

SQL> alter database commit to switchover to primary with session shutdown wait ;

Database altered.

(3) Check the status of the stock

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS

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

bhtcdg MOUNTED PRIMARY NOT ALLOWED

(4) Open

SQL> alter database open;

Database altered.

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STAT

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

bhtcdg READ WRITE PRIMARY RESOLVABLE GAP

3. Open database (machine A)

SQL> alter database open read only;

4. Application log (machine A)

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

3. validation data

(1) Create user in new master library (B machine)

SQL> create user test1 identified by test1;

SQL> commit;

SQL> alter system switch logfile;

System altered.

(2) Check in the new standby warehouse (A machine)

SQL> select username from dba_users where username='TEST1';

USERNAME

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

TEST1

4. Switch back to the original state

(1)New main library operation (B machine)

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

Database altered.

SQL> startup mount;

ORACLE instance started.

Total System Global Area 1.3429E+10 bytes

Fixed Size 2265944 bytes

Variable Size 6878661800 bytes

Database Buffers 6543114240 bytes

Redo Buffers 4612096 bytes

Database mounted.

(2) Operation of new standby warehouse (A machine)

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

Database altered.

SQL> alter database open;

Database altered.

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS

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

bhtcdb READ WRITE PRIMARY RESOLVABLE GAP

(3) B machine operation

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS

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

bhtcdg MOUNTED PHYSICAL STANDBY NOT ALLOWED

(4) Open the backup library and start real-time synchronization.

SQL> alter database open read only;

Database altered.

SQL> alter database recover managed standby database using current logfile disconnect;

Database altered.

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STAT

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

bhtcdg READ ONLY PHYSICAL STANDBY NOT ALLOWED

WITH APPLY

(5) Look at the A again

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS

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

bhtc db READ WRITE PRIMARY TO STANDBY

At this point, it has switched back to its original state.

(6) Backup Library View Log Application

SQL> select sequence#,applied from v$archived_log;

SEQUENCE# APPLIED

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

8 YES

7 YES

9 YES

10 YES

11 YES

12 YES

13 YES

13 YES

14 YES

14 YES

15 YES

SEQUENCE# APPLIED

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

15 YES

16 YES

16 YES

17 YES

17 NO

18 YES

19 YES

20 YES

21 IN-MEMORY

---------- end ----------

Tags: Status switching data log library application authentication again command real-time situation database user role synchronization Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Docker Shulou Tech Info Linux