Data Guard Physical Standby Setup in Oracle11.2 & 后加 Data Guard Broker 之02 (switchover) 切换测试

1.将主数据库转换为备用数据库(主库上)

[oracle@xag1124a ~]$  sqlplus / as sysdba

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

SQL> shutdown immediate
ORA-01012: not logged on

SQL> startup

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

SQL> select database_role,switchover_status from v$database;

PHYSICAL STANDBY        TO PRIMARY

SQL> archive log list;

SQL> select log_mode,open_mode,flashback_on from v$database;

LOG_MODE     OPEN_MODE		  FLASHBACK_ON
------------ -------------------- ------------------
ARCHIVELOG   READ ONLY WITH APPLY NO

2.将备用数据库转换为主数据库(老备库)

[oracle@xag1124b ~]$  sqlplus / as sysdba

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

SQL> shutdown immediate
ORA-01109: database not open

SQL> startup

SQL> alter system switch logfile;

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE	 SWITCHOVER_STATUS
---------------- --------------------
PRIMARY 	 TO STANDBY

SQL> archive log list;

SQL> select log_mode,open_mode,flashback_on from v$database;

LOG_MODE     OPEN_MODE		  FLASHBACK_ON
------------ -------------------- ------------------
ARCHIVELOG   READ WRITE 	  NO


第二轮切换开始(再次切换)

3.将新主数据库转换为备用数据库(新主库上)

[oracle@xag1124b ~]$  sqlplus / as sysdba

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

SQL> shutdown immediate
ORA-01012: not logged on

SQL> startup

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

SQL> select database_role,switchover_status from v$database;

PHYSICAL STANDBY        TO PRIMARY

SQL> archive log list;

SQL> select log_mode,open_mode,flashback_on from v$database;

LOG_MODE     OPEN_MODE		  FLASHBACK_ON
------------ -------------------- ------------------
ARCHIVELOG   READ ONLY WITH APPLY NO

4.将新备用数据库转换为主数据库(备库)

[oracle@xag1124a ~]$  sqlplus / as sysdba

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

SQL> shutdown immediate
ORA-01109: database not open

SQL> startup

SQL> alter system switch logfile;

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE	 SWITCHOVER_STATUS
---------------- --------------------
PRIMARY 	 TO STANDBY

SQL> archive log list;

SQL> select log_mode,open_mode,flashback_on from v$database;

LOG_MODE     OPEN_MODE		  FLASHBACK_ON
------------ -------------------- ------------------
ARCHIVELOG   READ WRITE 	  NO

上一篇:目录结构与文件处理


下一篇:用SQL*Plus命令启动和关闭数据库