chover)切换测试
--primary 做如下操作
SQL> alter database commit to switchover to physical standby;
Database altered.
SQL> shutdown immediate
ORA-01012: not logged on
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1188511744 bytes
Fixed Size 1364228 bytes
Variable Size 754978556 bytes
Database Buffers 419430400 bytes
Redo Buffers 12738560 bytes
Database mounted.
Database opened.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY TO PRIMARY
SQL>
--standby 端做如下操作
SQL> alter database commit to switchover to primary;
Database altered.
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1188511744 bytes
Fixed Size 1364228 bytes
Variable Size 754978556 bytes
Database Buffers 419430400 bytes
Redo Buffers 12738560 bytes
Database mounted.
Database opened.
SQL> alter system switch logfile;
System altered.
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY SESSIONS ACTIVE
SQL>
16、ADG做(fail over)切换测试
--standby 端检查状态
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
--我们通过shutdown abort方式人工模拟primary奔溃,直接关闭:
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL> shutdown abort
ORACLE instance shut down.
SQL>
--在standby端执行如下操作
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1188511744 bytes
Fixed Size 1364228 bytes
Variable Size 754978556 bytes
Database Buffers 419430400 bytes
Redo Buffers 12738560 bytes
Database mounted.
SQL> alter system flush redo to 'pri';
System altered.
SQL> select thread#, low_sequence#, high_sequence# from v$archive_gap;
no rows selected
--如果没有发现明显的gap现象,说明此次的failover不会有数据损失情况。在standby端,要进行关闭apply和结束应用动作。
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database recover managed standby database finish;
Database altered
SQL> select open_mode, switchover_status from v$database;
OPEN_MODE SWITCHOVER_STATUS
-------------------- --------------------
READ ONLY TO PRIMARY