程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SyBase數據庫 >> SyBase教程 >> 如何利用閃回數據庫特性恢復failover後的dataguard環境?

如何利用閃回數據庫特性恢復failover後的dataguard環境?

編輯:SyBase教程

如何利用閃回數據庫特性恢復failover後的dataguard環境?


11g dataguard standby 切成主庫,測試完成後恢復為原standby 環境


#######################
概述:
11204 單機對單機實施dg,因局方要求需要(讀寫模式)打開standby ;而這時原生產環境不能有任何影響動,依然對外服務;
采用的思路是:standby 直接failover 為primary db;這時原有dg關系被破壞,互不影響;


#######################
思路概要:
1.確認主庫歸檔日志存放空間是否足夠?(需考慮歸檔保留刪除策略?);關閉主庫到備庫的日志傳輸
2.備庫確認是否開啟flashback database,以及閃回日志存放空間是否充足?
3.備庫failover to primary (切換前確認是否日志延遲傳輸?手工注冊)
4.業務測試
5.恢復failover 備庫
6.確認dg 環境恢復是否正常(日志自動傳輸和應用?)?



#######################
具體實施步驟:

------主庫defer 日志傳輸
alter system set log_archive_dest_2=defer;

---enable 日志傳輸:
alter system set log_archive_dest_2=enable;

-----備庫(mount)配置 flashback database:
STANDBY DATABASE: Stop redo apply, configure flashback retention,
start flashback database, open the database and start redo apply (Is active DG).

---檢查備庫是否啟用flashback database:
select flashback_on from v$database;


注意這裡需要確認下備庫打開模式: mount?readonly with apply?
在11g 環境下備庫可能啟用了 ADG 特性 備庫日志處於實時應用,數據庫模式為 readonly with apply
這時需要重啟數據庫到mount狀態修改flashback database 模式;


如果備庫處於mount 狀態,可以先取消日志apply ,直接打開閃回數據庫特性;


---取消備庫日志應用:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;


---需要配置一下兩個參數來打開flashback database 特性:
ALTER SYSTEM SET db_recover_file_dest='/lixora/lixora/lixora/';
ALTER SYSTEM SET db_recover_file_dest_size=100G;

ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=240; ---4hours
ALTER DATABASE FLASHBACK ON;

--手工創建還原點(該步驟沒有測試過):
Creating Restore point in Physical Standby:
CREATE RESTORE POINT before_damage GUARANTEE FLASHBACK DATABASE


-------備庫failover to primary db 應急切換步驟:
(注:模擬主庫由於故障無法正常switchover,需要執行failover,強制備庫->pridb並接管業務)

1.備庫:
由於是failover,所以理解主庫這時候已經無法正常使用,只需備庫切換至pridb

【前提主庫還是可用的:可選】查詢沒有應用的日志:
SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;

select distinct thread#,max(sequence#) over(partition by thread#) a from v$archived_log;
該語句取得當前數據庫各線程已歸檔文件最大序號,如果primary 與standby 最大序號不相同,
必須將多出的序號對應的歸檔文件復制到待轉換的standby服務器。


Cp過來並register
ALTER DATABASE REGISTER PHYSICAL LOGFILE 'filespec1'

停止應用恢復模式
alter database recover managed standby database finish;
or
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH FORCE;

轉換standbydb為primary db
alter database commit to switchover to primary;


重啟數據庫,恢復正常業務
alter database open;


數據庫角色查看:
select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------- ----------------
OPEN PRIMARY


------恢復failover 的備庫:
C. Using SQL*PLUS
Step 1 Determine the Standby Became Primary SCN.
Step 2 Flashback the Failed Primary Database.
Step 3 Convert to physical standby database.
Step 4 Restart Redo Transport.
Step 5 Start Redo Apply.


Step 1 Determine the SCN at which the old standby database became the primary database.
SQL> SELECT TO_CHAR(STANDBY_BECAME_PRIMARY_SCN) FROM V$DATABASE;


Step 2 Flashback the Failed Primary Database to SCN standby_became_primary_scn.
SQL> SHUTDOWN IMMEDIATE;
SQL> startup mount
SQL> FLASHBACK DATABASE TO SCN ;

Step 3 Convert the database to a physical standby database and Restart database in mount stage.
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;


Step 4 Restart Redo Transport to the New Physical Standby Database.
1. If you have not set the remote archive destination on current primary then set remote archive destination:
SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_2 = 'SERVICE=lixora VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lixora' SCOPE=BOTH;

2. Enable the destination
SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;

3. Perform a log switch to ensure that standby database begins receiving redo data from the new primary database
SQL> ALTER SYSTEM SWITCH LOGFILE;
SQL> SELECT DEST_ID, STATUS, ERROR FROM V$ARCHIVE_DEST WHERE DEST_ID=2;


--確認日志是否都apply了?
select applied from v$archived_log;

select message from v$dataguard_status;


Step 5 Start Redo Apply.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Please see also fallowing docu:


TIPS:
Oracle? Data Guard Concepts and Administration
11g Release 2 (11.2)
13.2 Converting a Failed Primary Into a Standby Database Using Flashback Database

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved