Environment:
OS: rhel63_64bit
DB: Oracle10gR2
Master/Slave switchover sequence: first from the master database to the slave database, then from the slave database to the master database
Switchover:
Lossless conversion is usually triggered manually or scheduled by users, such as hardware upgrades and software upgrades.
Generally, the workload it brings to you is very small and predictable. Its execution is divided into two stages. The first step is to convert the primary database to the standby role. The second step is to convert the standby database (one) to the primary role. The primary and standby are only simple role swaps, this also confirms our previous speculation that role conversion is a primary/standby interaction.
Failover:
Unpredictable causes cause the primary database to fail and cannot be recovered in a short period of time. If this is the switch, you should be careful. It may be just a false shock, or even estimate the number of brain cells that you may lose, however, if you are not lucky and do not have a complete Backup recovery policy and the primary data is not in the maximum data protection or highest availability mode
SWITCHOVER_STATUSVARCHAR2 (18) Indicates whether switchover is allowed:
■ Not allowed-Either this is a standby database and the primary
Database has not been switched first or this is a primary database
And there are no standby databases.
■ Sessions active-Indicates that there are active SQL sessions
Attached to the primary or standby database that need to be
Disconnected before the switchover operation is permitted. Query
TheV $ SESSIONviewtoidentifythespecificprocessesthatneedto
Be terminated.
■ Switchover pending-This is a standby database and
Primary database switchover request has been received Ed but not
Processed.
■ Switchover latent-The switchover was in pending mode,
But did not complete and went back to the primary database.
■ TOPRIMARY-Thisisastandbydatabaseandisallowedtoswitch
Over to a primary database.
■ TOSTANDBY-thisispolicmarydatabaseandisallowedtoswitch
Over to a standby database.
■ Recovery needed-This is a standby database that has not
Received the switchover request.
Master database operations
SQL> select process, pid, status, client_process from v $ managed_standby;
Process pid status CLIENT_P
---------------------------------------
ARCH 7913 CONNECTED ARCH
ARCH 7915 CONNECTED ARCH
Archive 7917 CLOSING ARCH
ARCH 7919 CONNECTED ARCH
ARCH 7921 CONNECTED ARCH
ARCH 7923 CONNECTED ARCH
ARCH 7925 CONNECTED ARCH
ARCH 7927 CONNECTED ARCH
ARCH 7929 CONNECTED ARCH
ARCH 7931 CONNECTED ARCH
LGWR 7893 writing lgwr.
11 rows selected.
SQL> select DATABASE_ROLE, switchover_status from v $ database;
DATABASE_ROLE SWITCHOVER_STATUS
------------------------------------
PRIMARY SESSIONS ACTIVE
SQL>
Sys @ ORA> select count (*) from v $ session where username is not null;
COUNT (*)
----------
1
SQL> startup force
ORACLE instance started.
Total System Global Area 213909504 bytes
Fixed Size 2095152 bytes
Variable Size 88082384 bytes
Database Buffers 117440512 bytes
Redo Buffers 6291456 bytes
Database mounted.
Database opened.
SQL> select DATABASE_ROLE, switchover_status from v $ database;
DATABASE_ROLE SWITCHOVER_STATUS
------------------------------------
PRIMARY SESSIONS ACTIVE
SQL> SELECT COUNT (*) FROM V $ SESSION WHERE USERNAME IS NOT NULL;
COUNT (*)
----------
1
Directly switch without other sessions
SQL> select sequence #, applied from dba_logstdby_log;
No rows selected
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
Database altered.
SQL> alter database commit to switchover to standby;
Database altered.
SQL> select instance_name, status from v $ instance;
INSTANCE_NAME STATUS
----------------------------
Ora STARTED
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 213909504 bytes
Fixed Size 2095152 bytes
Variable Size 92276688 bytes
Database Buffers 113246208 bytes
Redo Buffers 6291456 bytes
Database mounted.
Sys @ ORA> select DATABASE_ROLE, switchover_status from v $ database;
DATABASE_ROLE SWITCHOVER_STATUS
------------------------------------
PHYSICAL STANDBY TO PRIMARY
SQL> select process, pid, status, client_process from v $ managed_standby;
Process pid status CLIENT_P
---------------------------------------
ARCH 8126 CONNECTED ARCH
ARCH 8128 CONNECTED ARCH
ARCH 8130 CONNECTED ARCH
ARCH 8132 CONNECTED ARCH
ARCH 8134 CONNECTED ARCH
ARCH 8136 CONNECTED ARCH
ARCH 8138 CONNECTED ARCH
ARCH 8140 CONNECTED ARCH
ARCH 8142 CONNECTED ARCH
ARCH 8144 CONNECTED ARCH
10 rows selected.
For more details, please continue to read the highlights on the next page:
Recommended reading:
Use the Duplicate function of RMAN to create a physical partition uard
Basic Oracle tutorial-copying a database through RMAN
Reference for RMAN backup policy formulation
RMAN backup learning notes
Oracle Database Backup encryption RMAN Encryption
Use RMAN to back up duplicate to create a replica uard