dataguard角色轉換—switchover
本文用的oracle為10g2
SYS>select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE
SYS>select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE
10.2.0.1.0
Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
一 將主庫切換為standby role
確定primary資料庫是否支援switchover操作
SYS>select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO STANDBY
顯示結果表示primary資料庫支援轉換為standby角色
將primary資料庫轉換為standby角色
SYS>alter database commit to switchover to physical standby with session shutdown;
Database altered.
將primary資料庫重啟到mount狀態
SYS>shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SYS>startup mount
ORACLE instance started.
Total System Global Area 595591168 bytes
Fixed Size 1220748 bytes
Variable Size 180359028 bytes
Database Buffers 406847488 bytes
Redo Buffers 7163904 bytes
Database mounted.
二 將備庫切換為primary role
確定待轉換的standby資料庫是否支援switchover操作
SYS>select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
顯示結果表示standby資料庫支援轉換為primary角色
將standby轉換為primary角色
SYS>alter database commit to switchover to primary;
Database altered.
角色轉換完成,啟動資料庫
SYS>shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SYS>startup
ORACLE instance started.
Total System Global Area 268435456 bytes
Fixed Size 1218868 bytes
Variable Size 92276428 bytes
Database Buffers 167772160 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.
原主庫(新的備庫)以REDO LOG實時APPLY的方式開啟和主資料庫的同步
SYS>alter database recover managed standby database using current logfile disconnect from session;
Database altered
三 同步測試
檢視當前資料庫的角色及資料庫名
select database_role,db_unique_name from v$database;
新primary
scott使用者下有這些表
SYS>select table_name from all_tables where owner='SCOTT';
TABLE_NAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
新的standby
SYS>alter database recover managed standby database cancel;
Database altered.
SYS>alter database open read only;
Database altered.
scott使用者下有這些表
SYS>select table_name from all_tables where owner='SCOTT';
TABLE_NAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
新primary
在scott使用者下建立表e
SYS>create table scott.e as select * from scott.emp;
Table created.
SYS>select table_name from all_tables where owner='SCOTT';
TABLE_NAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
E
新standby
應用redo log日誌
SYS>alter database recover managed standby database using current logfile disconnect from session;
Database altered.
檢視同步時間
SYS>select name,value from v$dataguard_stats;
NAME VALUE
-------------------------------- ----------------------------------------------------------------
apply finish time
apply lag +00 00:03:19
estimated startup time 8
standby has been open Y
transport lag +00 00:00:00
待同步完成即apply lag值為+00 00:00:00時停止日誌應用
SYS>alter database recover managed standby database cancel;
Database altered.
以只讀方式開啟資料庫
SYS>alter database open read only;
Database altered.
檢視是否有e表生成
SYS>select table_name from all_tables where owner='SCOTT';
TABLE_NAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
E
standby有e表生成,結果表明同步成功
四 錯誤處理
SYS>alter database commit to switchover to primary with session shutdown wait;
alter database commit to switchover to primary with session shutdown wait
*
ERROR at line 1:
ORA-16139: media recovery required
解決:
alter database recover managed standby database finish
alter database commit to switchover to primary;
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
一 將主庫切換為standby role
確定primary資料庫是否支援switchover操作
SYS>select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO STANDBY
顯示結果表示primary資料庫支援轉換為standby角色
將primary資料庫轉換為standby角色
SYS>alter database commit to switchover to physical standby with session shutdown;
Database altered.
將primary資料庫重啟到mount狀態
SYS>shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SYS>startup mount
ORACLE instance started.
Total System Global Area 595591168 bytes
Fixed Size 1220748 bytes
Variable Size 180359028 bytes
Database Buffers 406847488 bytes
Redo Buffers 7163904 bytes
Database mounted.
二 將備庫切換為primary role
確定待轉換的standby資料庫是否支援switchover操作
SYS>select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
顯示結果表示standby資料庫支援轉換為primary角色
將standby轉換為primary角色
SYS>alter database commit to switchover to primary;
Database altered.
角色轉換完成,啟動資料庫
SYS>shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SYS>startup
ORACLE instance started.
Total System Global Area 268435456 bytes
Fixed Size 1218868 bytes
Variable Size 92276428 bytes
Database Buffers 167772160 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.
原主庫(新的備庫)以REDO LOG實時APPLY的方式開啟和主資料庫的同步
SYS>alter database recover managed standby database using current logfile disconnect from session;
Database altered
三 同步測試
檢視當前資料庫的角色及資料庫名
select database_role,db_unique_name from v$database;
新primary
scott使用者下有這些表
SYS>select table_name from all_tables where owner='SCOTT';
TABLE_NAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
新的standby
SYS>alter database recover managed standby database cancel;
Database altered.
SYS>alter database open read only;
Database altered.
scott使用者下有這些表
SYS>select table_name from all_tables where owner='SCOTT';
TABLE_NAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
新primary
在scott使用者下建立表e
SYS>create table scott.e as select * from scott.emp;
Table created.
SYS>select table_name from all_tables where owner='SCOTT';
TABLE_NAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
E
新standby
應用redo log日誌
SYS>alter database recover managed standby database using current logfile disconnect from session;
Database altered.
檢視同步時間
SYS>select name,value from v$dataguard_stats;
NAME VALUE
-------------------------------- ----------------------------------------------------------------
apply finish time
apply lag +00 00:03:19
estimated startup time 8
standby has been open Y
transport lag +00 00:00:00
待同步完成即apply lag值為+00 00:00:00時停止日誌應用
SYS>alter database recover managed standby database cancel;
Database altered.
以只讀方式開啟資料庫
SYS>alter database open read only;
Database altered.
檢視是否有e表生成
SYS>select table_name from all_tables where owner='SCOTT';
TABLE_NAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
E
standby有e表生成,結果表明同步成功
四 錯誤處理
SYS>alter database commit to switchover to primary with session shutdown wait;
alter database commit to switchover to primary with session shutdown wait
*
ERROR at line 1:
ORA-16139: media recovery required
解決:
alter database recover managed standby database finish
alter database commit to switchover to primary;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27181165/viewspace-775871/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Dataguard物理Standby Switchover 角色轉換
- 【DataGuard】Oracle 11g DataGuard 角色轉換(一)物理備庫SwitchoverOracle
- 物理dataguard 正常切換 角色轉換,switchover_status 狀態改變
- DataGuard---->物理StandBy的角色切換之switchover
- 物理DG角色轉換:switchover
- Oracle DataGuard switchover切換一例Oracle
- 【DATAGUARD】物理dg的switchover切換(五)
- DataGuard SwitchOver
- 備庫的切換狀態為SWITCHOVER PENDING時進行dataguard主備庫角色切換
- 物理dataguard 正常切換 腳色轉換,switchover_status 狀態改變
- dataguard手動switchover切換步驟及注意的問題 轉
- DataGuard:Physical Standby Switchover
- Oracle DataGuard 主備切換 (switchover) oracle11gOracle
- DATAGUARD在做SWITCHOVER切換時遇到問題總結
- Dataguard Physical Standy Switchover
- 10g_dataguard_switchover
- DataGuard:Logical Standby Switchover
- 10g Data Guard physical standby的主備庫角色轉換測試(switchover & failover)AI
- Oracle 10g DataGuard物理主備切換-switchover與failoverOracle 10gAI
- 【DataGuard】10g物理standby主備switchover方式切換詳述
- oracle dataguard 進行switchover測試Oracle
- 9 Role Transitions 角色轉換
- 【DataGuard】Oracle 11g physical standby switchoverOracle
- dataguard switchover & failover steps (rac)AI
- 物理DG角色轉換: failoverAI
- 【DataGuard】使用Grid Control對Oracle物理Data Guard進行Switchover切換Oracle
- oracle11g dataguard完全手冊--switchoverOracle
- Oracle 11g Active Dataguard Switchover實驗Oracle
- dataguard型別轉換與模式轉化型別模式
- data guard物理備份方式中的switchover轉換
- dataguard主備switchover互切實驗及理解
- dataguard switchover的自動化指令碼實現指令碼
- ORACLE10G DG角色轉換Oracle
- ORACLE 11G Data Guard 角色轉換Oracle
- 【DataGuard】物理Data Guard之Failover轉換AI
- DataGuard之switchover_status狀態not allowed解決過程
- oracle dataguard 切換Oracle
- DATA GUARD物理STANDBY的 SWITCHOVER切換