oracle 11g dg broker 開啟fast-start failover自動故障切換
一.首先保證主從數據庫的閃回數據庫功能以及強制歸檔都打開,如下保證都為yes
SQL> select flashback_on,force_logging from v$database;
FLASHBACK_ON FOR
------------------ ---
NO NO
1.1開啟閃回數據庫
SQL> ALTER SYSTEM SET db_recovery_file_dest_size=3g SCOPE=BOTH;
System altered.
SQL> alter system set db_recovery_file_dest='/data/u01/app/oracle/fast_recovery_area';
System altered.
SQL> alter database flashback on;
Database altered.
1.2開啟強制歸檔
SQL> alter database force logging;
Database altered.
SQL> select flashback_on,force_logging from v$database;
FLASHBACK_ON FOR
------------------ ---
YES YES
二:開啟fast-start failover
2.1:開啟 fast-start failover
[oracle@beijing-fuli-hadoop-02 ~]$ dgmgrl sys/
oracle@db2
DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL> enable fast_start failover;
Enabled.
2.2.查看配置狀態,發現警告,因為沒有啟動observer而告警!
DGMGRL> show configuration
Configuration - dbha_c
Protection Mode: MaxPerformance
Databases:
db2 - Primary database
Warning: ORA-16819: fast-start failover observer not started
db1 - (*) Physical standby database
Warning: ORA-16819: fast-start failover observer not started
Fast-Start Failover: ENABLED
Configuration Status:
WARNING
2.3開啟 啟動觀察器(observer):
DGMGRL> show configuration
Configuration - dbha_c
Protection Mode: MaxPerformance
Databases:
db2 - Primary database
db1 - (*) Physical standby database
Fast-Start Failover: ENABLED
Configuration Status:
SUCCESS
由于observer的啟動會一直占用session 窗口的,所以建議寫成腳本掛后臺
這里我們在備庫上創建腳本,具體如下
創建一個名叫observer.sql的腳本,把下面的命令放進去,然后執行該腳本即可。
nohup dgmgrl sys/oracle@db2 "start observer">>observer.log 2>&1 &
三:驗證自動切換:
db2主庫:
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE
db1為standby
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY
db2主庫模擬異常關閉
SQL> shu abort
ORACLE instance shut down.
再次查看db1的狀態:
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE