【Data guard】Failover切换

FAILOVER 切换

 

1.  查询备库角色及状态( AB 机)

 

SQL> col db_unique_name for a15

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE DATABASE_ROLE    SWITCHOVER_STATUS

--------------- -------------------- ---------------- --------------------

db02            READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED

 

2.  主机模拟故障关机( A 机)

 

SQL> shutdown abort

ORACLE instance shut down.

 

3.  检测备库归档日志是否有 GAP B 机)

 

SQL> select thread#,low_sequence#,high_sequence# from v$archive_gap;

no rows selected

 

没有明显的 GAP 现象,说明此次 FAILOVER 不会有数据丢失的现象。在 standby 端,要进行关闭 apply 和结束应用动作。

 

4.  备库进行关闭 apply 和结束 apply 动作( B 机)

 

SQL> alter database recover managed standby database cancel;  

SQL> alter database recover managed standby database finish;

 

5.  备库进行切换( B 机)

 

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

 

6.  开启备库( B 机)

 

SQL> alter database open;

 

7.  查看备库角色( B 机)

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE DATABASE_ROLE    SWITCHOVER_STATUS

--------------- -------------------- ---------------- --------------------

db02            READ WRITE           PRIMARY          RESOLVABLE GAP

 

此时 FAILOVER 切换完成

 

 

 

FAILOVER 还原

 

复制 数据库

 

1.  A 开启到 nomount 模式 A 机)

 

SQL > startup nomount;

 

2.  RMAN 进行 复制 B 机)

 

[ oracle@primary ~ ]$   rman target sys/oracle@db02 auxiliary sys/oracle@db0 1

 RMAN>duplicate target database for standby nofilenamecheck from active database;

 

3.  A 机开启实时应用( A 机)

 

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

 

SQL>  alter database open read only;

Database altered.

 

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

Database altered.

 

4.  查看 AB 机状态

 

A 机)

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE DATABASE_ROLE    SWITCHOVER_STATUS

--------------- -------------------- ---------------- --------------------

db01  READ ONLY WITH APPLY    PHYSICAL STANDBY RECOVERY NEEDED

 

B 机)

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE   DATABASE_ROLE    SWITCHOVER_STATUS

--------------- -------------------- ---------------- --------------------

db02            READ WRITE           PRIMARY          SESSIONS ACTIVE

 

 

AB 库切换

(1) 主库操作( B

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

Database altered.

 

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area 1.3429E+10 bytes

Fixed Size                  2265944 bytes

Variable Size            6878661800 bytes

Database Buffers         6543114240 bytes

Redo Buffers                4612096 bytes

Database mounted.

 

(2) 备库 操作( A 机)

 

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

Database altered.

 

SQL> alter database open;

Database altered.

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE  DATABASE_ROLE    SWITCHOVER_STATUS

--------------- -------------------- ---------------- --------------------

Db01                 READ WRITE            PRIMARY            RESOLVABLE GAP

 

3 B 操作

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME   OPEN_MODE    DATABASE_ROLE   SWITCHOVER_STATUS

-------------------- -------------------- ---------------- --------------------

Db02                 MOUNTED        PHYSICAL STANDBY  NOT ALLOWED

 

4 )打开备库开启实时同步( B 机)

 

SQL> alter database open read only;

Database altered.

 

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

Database altered.

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE  DATABASE_ROLE    SWITCHOVER_STAT

--------------- ---------- ---------------- ---------------

Db02               READ ONLY  PHYSICAL STANDBY NOT ALLOWED

                   WITH APPLY

 

5 )再次查看 A 机( A 机)

 

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

 

DB_UNIQUE_NAME  OPEN_MODE    DATABASE_ROLE    SWITCHOVER_STATUS

--------------- -------------------- ---------------- --------------------

Db01            READ WRITE            PRIMARY           TO STANDBY

 

此时 ,已经切换回最初的状态

 

---------- end ----------



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31529886/viewspace-2284245/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31529886/viewspace-2284245/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值