單節點DG的switchover切換介紹
本章主要介紹DG的switchover切換,當用方法論來統籌知識和經驗的時候,操作筆記的價值並不大,不過新手可以借鑑
PRIMARY:
主庫是處於open狀態,有業務訪問,v$database檢視中的switchover_status欄位為sessions active
由primary切換到standby需要資料庫為open狀態,若v$database檢視中的switchover_status欄位為sessions active,執行切換命令時,帶上with session shutdown選項即可
SQL> select database_role,switchover_status from v$database;
SQL> alter database commit to switchover to physical standby with session shutdown;
SQL> shutdown abort;
SQL> startup mount;
SQL> alter database recover managed standby database disconnect from session/using current logfile disconnect from session;
SQL> select database_role,switchover_status from v$database;
PHYSICAL STANDBY:
確認是否可以切換為主庫,如果switchover_status為recovery needed或switchover latent,需要apply完所有歸檔日誌才能切換
如果是sessions active則帶上with session shutdown選項。apply完所有日誌後,即可切換為primary,然後開啟資料庫
檢視alert.log可以看到備庫做了哪些動作:接收主庫日誌,接收到主庫End-Of-REDO的訊號,apply完所有日誌,清空online redo log以便開啟資料庫,切換為primary,開啟資料庫
SQL> select database_role,switchover_status from v$database;
SQL> alter database recover managed standby database disconnect from session; #結束備庫歸檔apply
SQL> alter database commit to switchover to primary with session shutdown;
SQL> alter database open;
SQL> select database_role,switchover_status from v$database;
------------------------------------------------------------------------------------------------------------------------------------------
以上過過程中,由於主庫斷開所有session並歸檔,傳輸日誌到備庫,發給備庫End-Of-REDO的訊號,因此正常switchover時,是不會丟失資料的。
切換完成後可以在主庫歸檔,驗證一下是否切換成功,備庫是否能正常接收日誌。
------------------------------------------------------------------------------------------------------------------------------------------
switchover 主備切換演練,操作筆記
PRIMARY:
SQL> show user
USER is "SYS"
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL>
PHYSICAL STANDBY:
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select sequence#,applied from v$archived_log;
SEQUENCE# APPLIED
---------- ---------
40 YES
41 YES
42 YES
44 YES
45 YES
43 YES
46 YES
47 YES
48 YES
49 IN-MEMORY
SQL> alter database recover managed standby database cancel;
Database altered.
此時,DG執行正常,接下來進行switchover切換
-------------------------------------------------------------------------------
PRIMARY:
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY TO STANDBY
SQL> alter database commit to switchover to physical standby;
Database altered.
注:若這邊發現switchover_status狀態為sessions active,則切換到physical standby時需要加上with session shutdown
執行完切換命令後,關閉資料庫,重新啟動資料庫到mount狀態,接受日誌傳輸,開啟日誌應用
SQL> shutdown immediate
SQL> startup mount;
ORACLE instance started.
Total System Global Area 409194496 bytes
Fixed Size 2228864 bytes
Variable Size 339742080 bytes
Database Buffers 62914560 bytes
Redo Buffers 4308992 bytes
Database mounted.
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY RECOVERY NEEDED
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 NOT ALLOWED
SQL>
-------------------------------------------------------------------------------
PHYSICAL STANDBY:
當主庫已經將database_role從PRIMARY切換至PHYSICAL STANDBY,此時檢視備庫的database_role和switchover_status
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> alter database commit to switchover to primary;
Database altered.
SQL> alter database open;
Database altered.
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY TO STANDBY
-------------------------------------------------------------------------------
驗證筆記
原備庫:
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
beiku OPEN
SQL>
SQL>
SQL>
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
原主庫
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
zhuku MOUNTED
SQL> select sequence#,applied from v$archived_log;
SEQUENCE# APPLIED
57 YES
56 YES
58 YES
59 YES
60 YES
61 YES
62 YES
63 YES
DG已經執行正常
至此,單節點DG的switchover切換已經完成,failover切換可能在後續的章節中介紹
PRIMARY:
主庫是處於open狀態,有業務訪問,v$database檢視中的switchover_status欄位為sessions active
由primary切換到standby需要資料庫為open狀態,若v$database檢視中的switchover_status欄位為sessions active,執行切換命令時,帶上with session shutdown選項即可
SQL> select database_role,switchover_status from v$database;
SQL> alter database commit to switchover to physical standby with session shutdown;
SQL> shutdown abort;
SQL> startup mount;
SQL> alter database recover managed standby database disconnect from session/using current logfile disconnect from session;
SQL> select database_role,switchover_status from v$database;
PHYSICAL STANDBY:
確認是否可以切換為主庫,如果switchover_status為recovery needed或switchover latent,需要apply完所有歸檔日誌才能切換
如果是sessions active則帶上with session shutdown選項。apply完所有日誌後,即可切換為primary,然後開啟資料庫
檢視alert.log可以看到備庫做了哪些動作:接收主庫日誌,接收到主庫End-Of-REDO的訊號,apply完所有日誌,清空online redo log以便開啟資料庫,切換為primary,開啟資料庫
SQL> select database_role,switchover_status from v$database;
SQL> alter database recover managed standby database disconnect from session; #結束備庫歸檔apply
SQL> alter database commit to switchover to primary with session shutdown;
SQL> alter database open;
SQL> select database_role,switchover_status from v$database;
------------------------------------------------------------------------------------------------------------------------------------------
以上過過程中,由於主庫斷開所有session並歸檔,傳輸日誌到備庫,發給備庫End-Of-REDO的訊號,因此正常switchover時,是不會丟失資料的。
切換完成後可以在主庫歸檔,驗證一下是否切換成功,備庫是否能正常接收日誌。
------------------------------------------------------------------------------------------------------------------------------------------
switchover 主備切換演練,操作筆記
PRIMARY:
SQL> show user
USER is "SYS"
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL>
PHYSICAL STANDBY:
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select sequence#,applied from v$archived_log;
SEQUENCE# APPLIED
---------- ---------
40 YES
41 YES
42 YES
44 YES
45 YES
43 YES
46 YES
47 YES
48 YES
49 IN-MEMORY
SQL> alter database recover managed standby database cancel;
Database altered.
此時,DG執行正常,接下來進行switchover切換
-------------------------------------------------------------------------------
PRIMARY:
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY TO STANDBY
SQL> alter database commit to switchover to physical standby;
Database altered.
注:若這邊發現switchover_status狀態為sessions active,則切換到physical standby時需要加上with session shutdown
執行完切換命令後,關閉資料庫,重新啟動資料庫到mount狀態,接受日誌傳輸,開啟日誌應用
SQL> shutdown immediate
SQL> startup mount;
ORACLE instance started.
Total System Global Area 409194496 bytes
Fixed Size 2228864 bytes
Variable Size 339742080 bytes
Database Buffers 62914560 bytes
Redo Buffers 4308992 bytes
Database mounted.
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY RECOVERY NEEDED
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 NOT ALLOWED
SQL>
-------------------------------------------------------------------------------
PHYSICAL STANDBY:
當主庫已經將database_role從PRIMARY切換至PHYSICAL STANDBY,此時檢視備庫的database_role和switchover_status
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> alter database commit to switchover to primary;
Database altered.
SQL> alter database open;
Database altered.
SQL> select database_role,switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY TO STANDBY
-------------------------------------------------------------------------------
驗證筆記
原備庫:
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
beiku OPEN
SQL>
SQL>
SQL>
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
原主庫
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
zhuku MOUNTED
SQL> select sequence#,applied from v$archived_log;
SEQUENCE# APPLIED
57 YES
56 YES
58 YES
59 YES
60 YES
61 YES
62 YES
63 YES
DG已經執行正常
至此,單節點DG的switchover切換已經完成,failover切換可能在後續的章節中介紹
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30310891/viewspace-1729973/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 單節點DG的failover切換介紹AI
- 【DATAGUARD】物理dg的switchover切換(五)
- 【DG】Data Guard主備庫Switchover切換
- Oracle 11g dg switchover切換操作流程Oracle
- ROSE HA切換節點導致DG失敗、恢復ROS
- 物理DG角色轉換:switchover
- ora11_node_dg(2)ADG做(switchover)切換測試
- RAC+單例項DG的切換單例
- DG的切換操作
- 9204RAC到單例項的SWITCHOVER切換單例
- DATA GUARD物理STANDBY的 SWITCHOVER切換
- RAC環境STANDBY的SWITCHOVER切換
- Oracle:DG 的 switchoverOracle
- 單例項DG切換中的虛擬IP單例
- javascript DOM元素節點操作簡單介紹JavaScript
- DATA GUARD物理備庫的SWITCHOVER切換
- DATA GUARD物理STANDBY的 SWITCHOVER切換[zt]
- DG中備庫為SWITCHOVER PENDING時是否能進行主備切換
- RAC環境的物理STANDBY的 SWITCHOVER切換
- Zookeeper 節點特性介紹
- Oracle DataGuard switchover切換一例Oracle
- mongodb叢集節點故障的切換方法MongoDB
- dg切換操作文件
- oracle dg切換操作示例Oracle
- 【DG】三大模式切換模式
- DataGuard---->物理StandBy的角色切換之switchover
- RAC環境LOGICAL STANDBY的SWITCHOVER切換
- 【DG】DG之Switchover和Failover的區別AI
- 使用Broker實現DG切換
- Oracle RAC DG手動切換Oracle
- DG_三大模式切換模式
- 簡單介紹Vue實現滑鼠懸浮切換圖片srcVue
- 【DATAGUARD】物理dg的failover切換(六)AI
- dg搭建 單點-單點
- rhel6.4-11.2.0.3-RAC搭建單節點DG
- 再次使用DGbroker做switchover主備切換
- Hadoop-HA節點介紹Hadoop
- 使用DG_broker工具管理DG之switchover