自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

【博文推薦】Oracle DataGuard 學(xué)習(xí)之 DataGuard FailOver案例

數(shù)據(jù)庫(kù) Oracle
Oracle DG(Dataguard)是目前比較常見(jiàn)的數(shù)據(jù)庫(kù)HA配置策略。通過(guò)實(shí)現(xiàn)Physical Standby和Logical Standby,可以實(shí)現(xiàn)數(shù)據(jù)冗余容錯(cuò)機(jī)制。防止在主庫(kù)出現(xiàn)嚴(yán)重故障,不能支持服務(wù)的時(shí)候,沒(méi)有快速的后備支持環(huán)境。

本博文出自51CTO博客客居天涯博主,有任何問(wèn)題請(qǐng)進(jìn)入博主頁(yè)面互動(dòng)討論!
博文地址:http://tiany.blog.51cto.com/513694/1617646


Oracle DG(Dataguard)是目前比較常見(jiàn)的數(shù)據(jù)庫(kù)HA配置策略。通過(guò)實(shí)現(xiàn)Physical Standby和Logical Standby,可以實(shí)現(xiàn)數(shù)據(jù)冗余容錯(cuò)機(jī)制。防止在主庫(kù)出現(xiàn)嚴(yán)重故障,不能支持服務(wù)的時(shí)候,沒(méi)有快速的后備支持環(huán)境。

在DG中,switchover和failover是兩個(gè)重要的概念,也是DG實(shí)現(xiàn)的核心。兩者共同點(diǎn)都是Primary和Standby角色切換,差異在于Planned和UnPlanned之分。Switchover關(guān)鍵點(diǎn)在于Planned,這個(gè)切換動(dòng)作是在運(yùn)維機(jī)構(gòu)規(guī)劃范圍內(nèi)的動(dòng)作。比如,進(jìn)行定期系統(tǒng)軟硬件升級(jí)、設(shè)備維修等動(dòng)作。而Failover是真正出現(xiàn)嚴(yán)重系統(tǒng)故障,如數(shù)據(jù)庫(kù)宕機(jī)、軟硬件故障導(dǎo)致的Primary不能支持服務(wù),從而進(jìn)行的切換動(dòng)作。

根據(jù)不同的DG配置,switchover和failover也是有差異的。理論上,Switchover是不會(huì)造成數(shù)據(jù)丟失的,Primary在切換之后也是在DG配置環(huán)境中,作為Standby存在的。但是Failover則不同,除了運(yùn)行在***保護(hù)(Maximum Protection)模式下,Primary突發(fā)的故障可能引起一部分Redo Log不能及時(shí)的傳遞到Standby端,切換之后很可能有數(shù)據(jù)損失的情況。更重要的是,Primary端在發(fā)生Failover之后,是不能夠直接加入回DG配置的!也就是說(shuō),F(xiàn)ailover之后,Primary實(shí)際上就是被“拋出”了DG環(huán)境。

那么,有什么方法實(shí)現(xiàn)Primary回到原有的環(huán)境呢?這個(gè)問(wèn)題的困難在于保持Primary和Standby一致。在正常情況下,Primary和Standby之間是關(guān)聯(lián)同步的,即使發(fā)生了Switchover,也在可控情況下。Failover過(guò)程中有數(shù)據(jù)的缺失,還有Primary修復(fù)問(wèn)題。在目前流行版本(11g)中,有三個(gè)方法:

  • 環(huán)境重建:一種最簡(jiǎn)單的方法就是直接刪除原來(lái)的Primary庫(kù),引用DG重建方法,重新搭建Standby端;
  • RMAN備份恢復(fù):如果Primary端保留過(guò)一份Failover之前的備份,則可以強(qiáng)制原來(lái)的Primary端恢復(fù)到進(jìn)行Failover的時(shí)間點(diǎn),之后作為Standby接收當(dāng)前Primary的redo log傳遞,應(yīng)用后可以跟上進(jìn)度;
  • Flashback Database恢復(fù):Flashback技術(shù)是作為傳統(tǒng)備份還原技術(shù)的補(bǔ)充,提供了更加便捷的恢復(fù)策略。使用flashback,可以將數(shù)據(jù)庫(kù)恢復(fù)到failover之前的時(shí)間點(diǎn)。之后的過(guò)程和RMAN備份恢復(fù)策略相同;

案例分析:

一、在主庫(kù)端模擬數(shù)據(jù)庫(kù)意外宕機(jī)

  1. 7scott@bjdb>conn /as sysdba 
  2. Connected. 
  3. sys@bjdb>alter system switch logfile; 
  4. System altered. 
  5. sys@bjdb>shutdown abort 
  6. ORACLE instance shut down. 

二、在備庫(kù)端

1、查看切換信息

  1. 5sys@shdb>select name,database_role,switchover_status from v$database; 
  2. NAME DATABASE_ROLE SWITCHOVER_STATUS 
  3. --------- ---------------- -------------------- 
  4. TESTDB12 PHYSICAL STANDBY NOT ALLOWED 
  5. 可以看到此時(shí)備庫(kù)處于無(wú)法切換狀態(tài) 

2、直接切換

  1. sys@shdb>alter database commit to switchover to primary; 
  2. alert_log:(告警日志) 
  3. Fatal NI connect error 12514, connecting to: 
  4. (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=shsrv)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=shdb)(CID=(PROGRAM=oracle)(HOST=bjsrv)(USER=oracle)))) 
  5. VERSION INFORMATION: 
  6. TNS for Linux: Version 11.2.0.3.0 - Production 
  7. TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.3.0 - Production 
  8. Time: 04-MAR-2015 21:25:13 
  9. Tracing not turned on. 
  10. Tns error struct: 
  11. ns main err code: 12564 
  12. TNS-12564: TNS:connection refused 
  13. ns secondary err code: 0 
  14. nt main err code: 0 
  15. nt secondary err code: 0 
  16. nt OS err code: 0 
  17. Error 12514 received logging on to the standby 
  18. FAL[client, MRP0]: Error 12514 connecting to shdb for fetching gap sequence 
  19. Wed Mar 04 21:26:00 2015 
  20. alter database commit to switchover to primary 
  21. ALTER DATABASE SWITCHOVER TO PRIMARY (TestDB12)  
  22. Maximum wait for role transition is 15 minutes.  
  23. Switchover: Media recovery is still active  
  24. Database not available for switchover  
  25. End-Of-REDO archived log file has not been recovered  
  26. Database not available for switchover  
  27. End-Of-REDO archived log file has not been recovered 
  28. Database not available for switchover 

3、關(guān)閉standby MPR進(jìn)程

  1. 35sys@shdb>ALTER DATABASE RECOVER managed standby database finish; 
  2. ALTER DATABASE RECOVER managed standby database finish  
  3. Terminal Recovery: request posted (TestDB12)  
  4. Wed Mar 04 21:34:34 2015 
  5. Begin: Standby Redo Logfile archival  
  6. End: Standby Redo Logfile archival  
  7. Terminal Recovery timestamp is '03/04/2015 21:34:34'  
  8. Terminal Recovery: applying standby redo logs.  
  9. Terminal Recovery: thread 1 seq# 34 redo required 
  10. Media Recovery Waiting for thread 1 sequence 34 
  11. Terminal Recovery: End-Of-Redo log allocation  
  12. Terminal Recovery: standby redo logfile 4 created '/dsk4/arch_bj/arch_1_0_820054583.log'  
  13. This standby redo logfile is being created as part of the  
  14. failover operation. This standby redo logfile should be  
  15. deleted after the switchover to primary operation completes.  
  16. Media Recovery Log /dsk4/arch_bj/arch_1_0_820054583.log 
  17. Terminal Recovery: log 4 reserved for thread 1 sequence 34  
  18. Recovery of Online Redo Log: Thread 1 Group 4 Seq 34 Reading mem 0 
  19. Mem# 0: /dsk4/arch_bj/arch_1_0_820054583.log 
  20. Identified End-Of-Redo (failover) for thread 1 sequence 34 at SCN 0xffff.ffffffff 
  21. Incomplete Recovery applied until change 1234252 time 03/04/2015 21:23:43
  22. MRP0: Media Recovery Complete (TestDB12)  
  23. Terminal Recovery: successful completion  
  24. Wed Mar 04 21:34:35 2015 
  25. ARCH: Archival stopped, error occurred. Will continue retrying 
  26. ORACLE Instance TestDB12 - Archival Error 
  27. ORA-16014: log 4 sequence# 34 not archived, no available destinations 
  28. ORA-00312: online log 4 thread 1'/dsk4/arch_bj/arch_1_0_820054583.log' 
  29. Forcing ARSCN to IRSCN for TR 0:1234252
  30. Attempt to set limbo arscn 0:1234252 irscn 0:1234252 
  31. Resetting standby activation ID 2865247982 (0xaac836ee 
  32. MRP0: Background Media Recovery process shutdown (TestDB12) 
  33. Terminal Recovery: completion detected (TestDB12) 
  34. Completed: ALTER DATABASE RECOVER managed standby database finish 

4、切換數(shù)據(jù)庫(kù)到Primary

  1. sys@shdb>select status from v$instance; 
  2. STATUS 
  3. ------------ 
  4. OPEN 
  5. sys@shdb>select name,database_role,switchover_status from v$database; 
  6. NAME DATABASE_ROLE SWITCHOVER_STATUS  
  7. --------- ---------------- --------------------  
  8. TESTDB12 PHYSICAL STANDBY TO PRIMARY  
  9. sys@shdb>alter database commit to switchover to primary;  
  10. Database altered.  
  11. sys@shdb>alter database open;  
  12. Database altered.  
  13. 告警日志:  
  14. alter database commit to switchover to primary  
  15. ALTER DATABASE SWITCHOVER TO PRIMARY (TestDB12)  
  16. Maximum wait for role transition is 15 minutes.  
  17. All dispatchers and shared servers shutdown  
  18. CLOSE: killing server sessions.  
  19. CLOSE: all sessions shutdown successfully.  
  20. Wed Mar 04 21:35:47 2015  
  21. SMON: disabling cache recovery 
  22. Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/bjdb/TestDB12/trace/TestDB12_ora_3146.trc 
  23. Standby terminal recovery start SCN: 1234251  
  24. RESETLOGS after incomplete recovery UNTIL CHANGE 1234252  
  25. Online log /dsk2/oradata/bjdb/redo01b.log: Thread 1 Group 1 was previously cleared 
  26. Online log /dsk1/oradata/bjdb/redo01a.log: Thread 1 Group 1 was previously cleared  
  27. Online log /dsk2/oradata/bjdb/redo02b.log: Thread 1 Group 2 was previously cleared 
  28. Online log /dsk1/oradata/bjdb/redo02a.log: Thread 1 Group 2 was previously cleared 
  29. Online log /dsk2/oradata/bjdb/redo03b.log: Thread 1 Group 3 was previously cleared 
  30. Online log /dsk1/oradata/bjdb/redo03a.log: Thread 1 Group 3 was previously cleared 
  31. Standby became primary SCN: 1234250 
  32. Wed Mar 04 21:35:47 2015 
  33. Setting recovery target incarnation to 3  
  34. AUDIT_TRAIL initialization parameter is changed back to its original value as specified in the parameter file. 
  35. Switchover: Complete - Database mounted as primary 
  36. Completed: alter database commit to switchover to primary 

三、原主庫(kù)修復(fù)后,開(kāi)機(jī)

  1. sys@bjdb>startup  
  2. ORACLE instance started.  
  3. Total System Global Area 442601472 bytes  
  4. Fixed Size 2229184 bytes  
  5. Variable Size 281021504 bytes  
  6. Database Buffers 155189248 bytes 
  7. Redo Buffers 4161536 bytes  
  8. Database mounted.  
  9. Database opened.  
  10. sys@bjdb>select name,database_role,switchover_status from v$database; 
  11. NAME DATABASE_ROLE SWITCHOVER_STATUS  
  12. --------- ---------------- -------------------- 
  13. TESTDB12 PRIMARY FAILED DESTINATION 

現(xiàn)在原來(lái)的主庫(kù)被修復(fù)后,整個(gè)DataGuara架構(gòu)已經(jīng)被破壞了,所以必須把原來(lái)的主庫(kù)構(gòu)建成新的備庫(kù),重新恢復(fù)DataGuard的環(huán)境。

四、重新構(gòu)建DataGuard

  1. 1sys@bjdb>select name,database_role from v$database; 

NAME DATABASE_ROLE

-------------------------------------------------- ----------------

TESTDB12 PHYSICAL STANDBY

 

責(zé)任編輯:Ophira 來(lái)源: 51CTO
相關(guān)推薦

2021-12-27 09:15:16

Oracle數(shù)據(jù)庫(kù)后端開(kāi)發(fā)

2009-07-03 09:44:30

Oracle Data

2011-07-05 16:18:14

DataGuardSTANDBY

2015-09-29 10:26:51

pythonlogging模塊

2021-11-08 08:29:57

Oracle數(shù)據(jù)庫(kù)后端開(kāi)發(fā)

2017-07-04 15:45:30

數(shù)據(jù)庫(kù)RACWindows平臺(tái)

2015-05-15 10:04:28

localhost

2015-06-17 09:34:09

軟件定義存儲(chǔ) 云存儲(chǔ)

2015-07-01 10:25:07

Docker開(kāi)源項(xiàng)目容器

2014-10-15 11:40:44

LNMP搭建LNMP

2014-12-12 10:46:55

Azure地緣組affinitygro

2015-06-15 13:06:23

項(xiàng)目項(xiàng)目經(jīng)驗(yàn)

2014-10-23 09:47:28

安全運(yùn)維Iperf

2010-01-18 09:03:15

Dataguard配置

2015-07-03 11:26:07

MySQL高可用架MHA

2015-04-21 09:28:58

ockerdocker監(jiān)控平臺(tái)監(jiān)控

2014-12-01 10:33:51

Python

2015-07-29 13:46:27

OpenStackIcehouse私有云實(shí)戰(zhàn)部署

2015-04-17 11:17:15

大數(shù)據(jù)大數(shù)據(jù)擇業(yè)

2014-12-23 11:23:14

DRBDHeartbeatNFS
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)