這篇文章主要為大家展示了“Oracle 11g dg broker如何自動failover”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“Oracle 11g dg broker如何自動failover”這篇文章吧。
成都創(chuàng)新互聯(lián)專注于鹿城網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供鹿城營銷型網(wǎng)站建設(shè),鹿城網(wǎng)站制作、鹿城網(wǎng)頁設(shè)計、鹿城網(wǎng)站官網(wǎng)定制、重慶小程序開發(fā)服務(wù),打造鹿城網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供鹿城網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
Oracle 11g dg broker自動failover驗證:
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主庫模擬異常關(guān)閉
SQL> shu abort
ORACLE instance shut down.
再次查看db1的狀態(tài):
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE
四:自動切換的過程:
4.1:測試大概需要10秒observer去探測到主庫發(fā)生故障!
DGMGRL> start observer;
Observer started
20:15:59.44 Thursday, July 04, 2019
Initiating Fast-Start Failover to database "db2"...
Performing failover NOW, please wait...
Failover succeeded, new primary is "db2"
20:16:01.77 Thursday, July 04, 2019
4.2 failover的過程和手工failover一樣,不管是自動failver,還是手動執(zhí)行FAILOVER TO ,都是執(zhí)行了用命令行failover的命令如下兩條命令:
alter database recover managed standby database finish force;---停止rfs進程
alter database commit to switchover to primary;---由open到mount
alter database open; ----read write 方式打開
發(fā)生failover的時候,通過如下可以看到確實是這么個過程
1).開始狀態(tài): rfs和mrp進程都正常
SQL> select process,status ,sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
--------- ------------ ----------
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CLOSING 14
RFS IDLE 0
RFS IDLE 15
RFS IDLE 0
MRP0 APPLYING_LOG 15
8 rows selected.
2).rsf進程消失
SQL> select process,status ,sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
--------- ------------ ----------
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CLOSING 14
MRP0 APPLYING_LOG 15
3).數(shù)據(jù)庫變成了mounted
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY MOUNTED
4)數(shù)據(jù)庫變成open write了
SQL> select DATABASE_ROLE,OPEN_MODE from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY READ WRITE
4.3:手動執(zhí)行failover;
DGMGRL> help failover
Changes a standby database to be the primary database
Syntax:
FAILOVER TO
當(dāng)發(fā)生failover的之后:
查看 configuration的狀態(tài):發(fā)現(xiàn)原來的主庫 needs to be reinstated,需要使用REINSTATE命令修復(fù)下,才能變成新的主庫的從庫!
DGMGRL> show configuration
Configuration - dbha_c
Protection Mode: MaxPerformance
Databases:
db2 - Primary database
Warning: ORA-16829: fast-start failover configuration is lagging
db1 - (*) Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated
Fast-Start Failover: ENABLED
Configuration Status:
WARNING
首先啟動原來的主庫到mount狀態(tài):
SQL> startup mount
DGMGRL> help reinstate
Changes a database marked for reinstatement into a viable standby
Syntax:
REINSTATE DATABASE
DGMGRL> REINSTATE DATABASE db1
Reinstating database "db1", please wait...
Reinstatement of database "db1" succeeded
再次查看原來的主庫:
SQL> select process,status ,sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
--------- ------------ ----------
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CONNECTED 0
ARCH CLOSING 5
RFS IDLE 0
RFS IDLE 0
RFS IDLE 0
RFS IDLE 6
MRP0 APPLYING_LOG 6
實際上reinstate就是執(zhí)行了下面的過程:
如果要轉(zhuǎn)換原來的主庫為新的備庫
要求原先的主庫必須開啟了flashbackup database的功能,在failover后,
1.查看從庫failover成為主的時候的scn號。
SQL> select STANDBY_BECAME_PRIMARY_SCN from v$database;
STANDBY_BECAME_PRIMARY_SCN
--------------------------
15468
2.閃回原來的主庫到15468 的scn號;
SQL>FLASHBACK DATABASE TO SCN 15468 ;
Database altered.
3.在原來主庫執(zhí)行切換:
SQL> alter database convert to physical standby ;
Database altered.
4.關(guān)閉原來的主庫
SQL>shu immediate
5.打開原來的主庫到mount狀態(tài),
SQL>startup mount;
6.在新的主庫上把新產(chǎn)生的日志歸檔到新的備庫
SQL>alter system archive log current;
7.打開mrp進程應(yīng)用日志,重演變化
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
5.查看狀態(tài):
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CLOSING
ARCH CONNECTED
ARCH CONNECTED
ARCH CLOSING
MRP0 APPLYING_LOG
RFS IDLE
RFS IDLE
RFS IDLE
至此將原來的主庫成為了新的主的standby了。。。。。
以上是“Oracle 11g dg broker如何自動failover”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!