Get the App
SLTechnology News&Howtos  ›  Database  › 

Oracle 11g dataguard active / standby handoff

Shulou Source: shulou.com Published: 2022-06-01 13:42:07 10月03日 Update

1. Check the environment of the master and standby

Dg1 node:

SQL > archive log list

Database log mode Archive Mode

Automatic archival Enabled

Archive destination / u01/oradata/tong/archive

Oldest online log sequence 59

Next log sequence to archive 61

Current log sequence 61

SQL >

Dg2 node:

SQL > archive log list

Database log mode Archive Mode

Automatic archival Enabled

Archive destination / u01/oradata/tong/archive

Oldest online log sequence 60

Next log sequence to archive 0

Current log sequence 61

SQL >

two。 View the roles of the master and slave

Dg1 node (primary role):

SQL > select switchover_status,database_role from v$database

SWITCHOVER_STATUS DATABASE_ROLE

--

TO STANDBY PRIMARY

SQL >

Dg2 node (standby role):

SQL > select switchover_status,database_role from v$database

SWITCHOVER_STATUS DATABASE_ROLE

--

NOT ALLOWED PHYSICAL STANDBY

SQL >

3. Execute the switch command (primary node) on the main library

SQL > alter database commit to switchover to physical standby;-- convert the primary role to the standby role

Database altered.

SQL > shutdown immediate-- close the database and start to mount state

ORA-01507: database not mounted

ORACLE instance shut down.

SQL > startup mount

Total System Global Area 830930944 bytes

Fixed Size 2217912 bytes

Variable Size 545261640 bytes

Database Buffers 281018368 bytes

Redo Buffers 2433024 bytes

Database mounted.

SQL > select switchover_status,database_role from vault database;-- View the status of the current primary role

SWITCHOVER_STATUS DATABASE_ROLE

--

TO PRIMARY PHYSICAL STANDBY

SQL >

4. Execute on slave library (standby node)

SQL > select switchover_status,database_role from vault database;-- View the status of the standby backup role

SWITCHOVER_STATUS DATABASE_ROLE

--

TO PRIMARY PHYSICAL STANDBY

SQL > alter database commit to switchover to primary;-- change the role of slave library to primary

Database altered.

SQL > select switchover_status,database_role from v$database

SWITCHOVER_STATUS DATABASE_ROLE

--

NOT ALLOWED PRIMARY

SQL > alter database open;-- Open the database

Database altered.

SQL >

5. Execute on slave library (standby node)

SQL > select switchover_status,database_role from v$database

SWITCHOVER_STATUS DATABASE_ROLE

--

RECOVERY NEEDED PHYSICAL STANDBY

SQL > ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;-- modify the previous master database to log application

Database altered.

SQL >

6. Test whether the active and standby nodes are switched successfully

Dg2 node (primary role):

SQL > select * from tt

A

-

one

three

four

five

six

seven

6 rows selected.

SQL > insert into tt values (8)

1 row created.

SQL > commit

Commit complete.

SQL > select * from tt where axi8

A

-

eight

SQL > alter system switch logfile

System altered.

SQL > /

System altered.

SQL > archive log list

Database log mode Archive Mode

Automatic archival Enabled

Archive destination / u01/oradata/tong/archive

Oldest online log sequence 78

Next log sequence to archive 80

Current log sequence 80

SQL >

Dg1 node (standby role):

SQL > archive log list

Database log mode Archive Mode

Automatic archival Enabled

Archive destination / u01/oradata/tong/archive

Oldest online log sequence 79

Next log sequence to archive 0

Current log sequence 80

SQL > alter database recover managed standby database cancel

Database altered.

SQL > alter database open read only

Database altered.

SQL > select * from tt

A

-

one

three

four

five

six

seven

eight

7 rows selected.

SQL >

Tags: Node role state switch data database success command log environment application check test Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Apple Shulou Technology Huawei Linux