1. Check the primary and standby environment
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>
2. View the role of the master backup
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. Perform a toggle command on the main library (primary node )
Sql> ALTER DATABASE commit to switchover to physical standby; --Convert the primary role to the standby role
Database altered.
sql> shutdown immediate--Shut down the database and boot 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 V$database; --View the status of the current primary role
Switchover_status Database_role
-------------------- ----------------
To PRIMARY physical STANDBY
Sql>
4. Executing on the standby (standby node )
Sql> select Switchover_status,database_role from V$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 the repository 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 Database
Database altered.
Sql>
5. Executing on the standby (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 main library for the log application
Database altered.
Sql>
6. Test whether the primary and standby node is successfully switched
DG2 node (primary role):
Sql> select * from TT;
A
----------
1
3
4
5
6
7
6 rows selected.
Sql> INSERT INTO TT values (8);
1 row created.
Sql> commit;
Commit complete.
Sql> SELECT * from TT where a=8;
A
----------
8
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
----------
1
3
4
5
6
7
8
7 rows selected.
Sql>
This article from "Together Through the Days" blog, reproduced please contact the author!
Oracle 11g Dataguard Primary and Standby switching