Oracle 11gR2 Database和Active Data Guard遷移案例
客戶一套核心系統由一臺Oracle Database 11.2.0.3.4單機和一臺Active Data Guard組成,分別執行在兩臺PC伺服器上,Oracle Linux 5.8 x86_64bit作業系統,兩臺伺服器都未接儲存裝置;由於原有裝置老舊等原因,現在要將這套Oracle資料庫系統(主庫和ADG庫)遷移到新採購的兩臺伺服器上,不跨版本,也不跨平臺。為了最小化停機時間,我們先用目前最新的RMAN 0級備份在兩臺新伺服器上restore database,之後將到目前為止的所有1級備份和歸檔日誌restore和recover到兩個資料庫上,在主資料庫正常停機之後把剩餘的歸檔和線上Redo日誌檔案應用到兩個新資料庫,使他們的資料到最新,且是一致的,最後開啟主資料庫,恢復ADG的同步,整個過程從凌晨0點開始停機,一直持續到了4:20才遷移成功,之間遇到了不少小的問題,再次進行記錄:
1.RMAN報錯。
RMAN在應用部分歸檔日誌之後收到如下報錯:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/13/2014 00:03:03
ORA-00283: recovery session canceled due to errors
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/oradata/bak/archivelog/2014_11_12/o1_mf_1_62193_b65oryl5_.arc'
ORA-00283: recovery session canceled due to errors
ORA-19755: could not open change tracking file
ORA-19750: change tracking file: '/u01/app/oracle/block_change_file'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
執行下面的SQL禁用block change tracking,資料庫即可繼續正常的應用archivelog:
SQL > alter database disable block change tracking;
Database altered.
參考文章:
2.resetlogs之後檢查主庫和備庫的日誌同步情況。
通常在主庫執行以下的SQL語句可以用於檢查主庫和備庫日誌同步情況:
SQL> select dest_id,thread#,max(sequence#) from v$archived_log where resetlogs_change#=936497858 group by dest_id,thread#;
DEST_ID THREAD# MAX(SEQUENCE#)
---------- ---------- --------------
2 1 9
1 1 9
由於主資料庫在開啟的時候執行了alter database open resetlogs,所以查詢v$archived_log要跟上resetlogs_change#,確保檢視的是現在資料庫的歸檔情況,resetlogs_change#可以透過v$database.resetlogs_change#獲得,另外,由於resetlogs開啟了資料庫,所以sequence#重新開始計數。
3.對活動的Standby LogFile的處理。
停止主資料庫之後,我們是想將原來的所有Online Redo Logfile和Standby Logfile都複製到新伺服器,透過alter databae rename file ... to ...的方式進行重新命名,沒想到的是Active的Standby Logfile無法進行重新命名(收到報錯:ORA-01511: error in renaming log/data files),但又必須將Standby Logfile檔案放在指定的目錄下,下面是查詢v$logfile的狀態:
SQL> select group#,member from v$logfile;
GROUP#
----------
MEMBER
--------------------------------------------------------------------------------
3
/oradata/orcl/REDO03.LOG
2
/oradata/orcl/REDO02.LOG
1
/oradata/orcl/REDO01.LOG
GROUP#
----------
MEMBER
--------------------------------------------------------------------------------
4
/u01/app/oracle/oradata/orcl/sredo01.log
5
/oradata/orcl/sredo02.log
6
/oradata/orcl/sredo03.log
GROUP#
----------
MEMBER
--------------------------------------------------------------------------------
7
/oradata/orcl/sredo04.log
7 rows selected.
group# 4是主資料庫之前的Active Standby Logfile,無法對其進行alter database rename file操作。
SQL> alter database drop logfile group 4;
alter database drop logfile group 4
*
ERROR at line 1:
ORA-00315: log 4 of thread 1, wrong thread # 0 in header
ORA-00312: online log 4 thread 1: '/u01/app/oracle/oradata/orcl/sredo01.log'
嘗試DROP GROUP組失敗。
SQL> alter database add logfile member '/oradata/orcl/sredo01.log' to group 4;
alter database add logfile member '/oradata/orcl/sredo01.log' to group 4
*
ERROR at line 1:
ORA-16161: Cannot mix standby and online redo log file members for group 4
嘗試新增成員失敗。
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 4;
ALTER DATABASE CLEAR LOGFILE GROUP 4
*
ERROR at line 1:
ORA-00350: log 4 of instance orcl (thread 1) needs to be archived
ORA-00312: online log 4 thread 1: '/u01/app/oracle/oradata/orcl/sredo01.log'
由於未歸檔所以直接CLEAR失敗。
SQL> ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 4;
Database altered.
CLEAR UNARCHIVED成功。
對Standby Logfile的處理辦法和對Online Redo Logfile的處理辦法一致。
SQL> select group#,thread#,status from v$standby_log;
GROUP# THREAD# STATUS
---------- ---------- ----------
4 1 UNASSIGNED
5 1 UNASSIGNED
6 1 UNASSIGNED
7 1 UNASSIGNED
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/oradata/orcl/REDO03.LOG
/oradata/orcl/REDO02.LOG
/oradata/orcl/REDO01.LOG
/u01/app/oracle/oradata/orcl/sredo01.log
/oradata/orcl/sredo02.log
/oradata/orcl/sredo03.log
/oradata/orcl/sredo04.log
7 rows selected.
SQL> alter database drop logfile group 4;
Database altered.
成功DROP該日誌組。
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/oradata/orcl/REDO03.LOG
/oradata/orcl/REDO02.LOG
/oradata/orcl/REDO01.LOG
/oradata/orcl/sredo02.log
/oradata/orcl/sredo03.log
/oradata/orcl/sredo04.log
6 rows selected.
SQL> select group#,thread#,bytes/1024/1024 mb from v$standby_log;
GROUP# THREAD# MB
---------- ---------- ----------
5 1 50
6 1 50
7 1 50
SQL> ALTER DATABASE ADD STANDBY LOGFILE group 4 ('/oradata/orcl/sredo01.log') SIZE 50M;
Database altered.
新增GROUP 4新的位置。
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/oradata/orcl/REDO03.LOG
/oradata/orcl/REDO02.LOG
/oradata/orcl/REDO01.LOG
/oradata/orcl/sredo01.log
/oradata/orcl/sredo02.log
/oradata/orcl/sredo03.log
/oradata/orcl/sredo04.log
7 rows selected.
完成Standby Logfile的遷移。
以下兩篇文章可用於該知識點的鞏固:
《ALTER DATABASE CLEAR UNARCHIVED LOGFILE的使用》:http://blog.itpub.net/23135684/viewspace-1098300/
《Redo丟失的4種情況及處理方法》:http://blog.itpub.net/23135684/viewspace-626935/
注意:以上的操作可能在備庫上無法完成,解決方法是,在主庫完成Standby Logfile遷移之後,主庫在MOUNT狀態下建立新的for Standby Controlfile(alter database create standby controlfile as '/tmp/controlf.ctl'; ),將新的Standby Controlfile和Standby Logfile傳遞到相同的位置,恢復備庫到一致狀態,開啟備庫,開始應用日誌即可。可以參考文章《Oracle Active Data Guard調整案例[2]》:http://blog.itpub.net/23135684/viewspace-1262326/
Data Guard備庫一定要是一致的狀態才能open read only開啟,否者執行alter database recover managed standby database應用日誌,恢復到一致性的狀態,再open read only。
4.主庫和備用庫無法實時同步。
原有的主資料庫和備用資料庫配置的時最高效能模式下的實時同步,完成遷移後無法進行實時同步,但歸檔切換後的同步正常。
首先主資料庫的LOG_ARCHIVE_DEST_2配置好了LGWR AFFIRM SYNC引數,備庫執行了如下應用命令:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
且主庫和備用庫的日誌傳輸服務正常工作。
在主資料庫和備用資料庫執行如下SQL語句:
SQL> select group#,thread#,status,bytes/1024/1024 mb from v$standby_log;
GROUP# THREAD# STATUS MB
---------- ---------- ---------- ----------
4 0 UNASSIGNED 100
5 0 UNASSIGNED 100
6 0 UNASSIGNED 100
7 0 UNASSIGNED 100
正常情況下,備用資料庫Standby Logfile Group至少有一個GROUP是Active的狀態,這裡沒有,所以不能實時同步資料,仔細觀察可以發現,這裡的Thread等於0,這或許就是備用資料庫找不到Standby Logfile進行實時同步的原因。
將備用資料庫啟動到MOUNT狀態,執行如下的SQL,指定Standby Logfile的Thread號:
SQL> startup mount
ORACLE instance started.
Total System Global Area 1.3683E+11 bytes
Fixed Size 2245480 bytes
Variable Size 8858373272 bytes
Database Buffers 1.2778E+11 bytes
Redo Buffers 189480960 bytes
Database mounted.
SQL> ALTER DATABASE ADD STANDBY LOGFILE thread 1 ('/oradata/orcl/sredo05.log') SIZE 100M reuse;
Database altered.
SQL> select group#,thread#,status,bytes/1024/1024 mb from v$standby_log;
GROUP# THREAD# STATUS MB
---------- ---------- ---------- ----------
4 0 UNASSIGNED 100
5 0 UNASSIGNED 100
6 0 UNASSIGNED 100
7 0 UNASSIGNED 100
8 1 UNASSIGNED 100
SQL> alter database drop logfile group 4;
Database altered.
SQL> alter database drop logfile group 5;
Database altered.
SQL> alter database drop logfile group 6;
Database altered.
SQL> alter database drop logfile group 7;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE thread 1 group 4 ('/oradata/orcl/sredo01.log') SIZE 100M reuse;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE thread 1 group 5 ('/oradata/orcl/sredo02.log') SIZE 100M reuse;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE thread 1 group 6 ('/oradata/orcl/sredo03.log') SIZE 100M reuse;
ALTER DATABASE ADD STANDBY LOGFILE thread 1 group 7 ('/oradata/orcl/sredo04.log') SIZE 100M reuse;
Database altered.
SQL> select group#,thread#,status,bytes/1024/1024 mb from v$standby_log;
GROUP# THREAD# STATUS MB
---------- ---------- ---------- ----------
4 1 UNASSIGNED 100
5 1 UNASSIGNED 100
6 1 UNASSIGNED 100
7 1 UNASSIGNED 100
8 1 ACTIVE 100
之後資料同步即恢復了正常工作,通常的操作還需要在主資料庫上完成,主庫和備庫實時同步期間會不斷的在兩個或多個Standby Logfile之間切換。
--end--
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29734436/viewspace-1337415/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 12.2 How to Generate AWRs in Active Data Guard Standby DatabasesOracleDatabase
- G008-ORACLE-DG ORACLE 19C Active Data Guard DML RedirectionOracle
- Oracle Data Guard和Broker概述Oracle
- Oracle Data Guard Broker元件Oracle元件
- Oracle Data Guard簡介Oracle
- A Oracle Data Guard Broker 升級和降級Oracle
- 1 關於 Oracle Data GuardOracle
- 2 Oracle Data Guard 安裝Oracle
- 1 Oracle Data Guard Broker 概念Oracle
- 4.1.6 Oracle Restart 與 Oracle Data Guard 整合OracleREST
- 8 Oracle Data Guard Broker 屬性Oracle
- 9 Oracle Data Guard 故障診斷Oracle
- 【ASK_ORACLE】Oracle Data Guard(一)DG架構Oracle架構
- oracle 11g data guard維護Oracle
- 【DATAGUARD】Oracle19c Data Guard BrokerOracle
- 2 開始實用 Oracle Data GuardOracle
- 19 Oracle Data Guard 相關檢視Oracle
- 使用Data Guard Broker進行Data Guard物理備用庫配置(Oracle 19c)Oracle
- 12c DG新特性 - Active Data Guard Far Sync (Doc ID 2179719.1)
- 異構資料庫資料遷移 oracle to mysql之oracle sqlloader和mysql load data資料庫OracleMySql
- 【ASK_ORACLE】Oracle Data Guard(二)物理備庫的概念和優勢Oracle
- 【ASK_ORACLE】Oracle Data Guard(四)快照備庫的概念和優勢Oracle
- 6 Oracle Data Guard Protection Modes 保護模式Oracle模式
- 15 Oracle Data Guard Scenarios 保護場景OracleiOS
- 【ASK_ORACLE】Oracle Data Guard(三)邏輯備庫的概念和優勢Oracle
- Oracle Data Guard Feature 12cR2系列(二)Oracle
- Oracle Data Guard Feature 12cR2系列(一)Oracle
- 18 與Oracle Data Guard 相關的SQL語句OracleSQL
- 遷移Report Server DataBase時遇到的坑ServerDatabase
- [20181018]Oracle Database 12c: Data Redaction.txtOracleDatabase
- 【mos 1265700.1】Oracle Patch Assurance - Data Guard Standby-First Patch ApplyOracleAPP
- oracle遷移OCR盤Oracle
- Oracle遷移文件大全Oracle
- Oracle遷移文章大全Oracle
- 模擬Oracle行遷移和行連結Oracle
- 單機搭建Data Guard
- Oracle 19C Data Guard基礎運維-02 Switchovers(物理)Oracle運維
- Oracle 19C Data Guard基礎運維-03 Failovers(物理)Oracle運維AI
- Oracle 19C Data Guard基礎運維-06 PROTECTION MODEOracle運維