Oracle 9+ Data Gard環境中重建控制檔案

Steven1981發表於2008-03-25

環境:LINUX AS 3+ORA 9.2.4 +DATA GUARD
MAX LOGFILES ,RESETLOGS

[@more@]

經過,已經搭建好了基於歸檔日記傳輸的最大效能保護模式的DG,想把它改成基於REDO 日記傳輸模式。在備庫新建STANDBY REDO 的時候報錯:

SQL> alter database add standby logfile group 4 ('/SERVER/ora9/oradata/ora9i/redo04.log') size 100M;

Database altered.

SQL> alter database add standby logfile group 5 ('/SERVER/ora9/oradata/ora9i/redo05.log') size 100M;

Database altered.

SQL> alter database add standby logfile group 6 ('/SERVER/ora9/oradata/ora9i/redo06.log') size 100M
*
ERROR at line 1:
ORA-01185: logfile group number 6 is invalid


SQL> alter database add standby logfile group 7 ('/SERVER/ora9/oradata/ora9i/redo07.log') size 100M
*
ERROR at line 1:
ORA-01185: logfile group number 7 is invalid

--出現這個錯誤是因為控制檔案中限制了MAX LOGFILES 最大日誌組數量。
像這種情況只能重建控制檔案。
但這是DG環境,處理控制檔案要特別的小心,如果搞不好就會DG環境被破壞,需要重建環境。(那樣工作量就大了)

1,匯出重建指令碼。
SQL> alter database backup controlfile to trace;

Database altered.
在新產生的Trace檔案中我們可以看到以下內容:
STARTUP NOMOUNT pfile=$ORACLE_HOME/dbs/initora9i.ora-as_primary
CREATE CONTROLFILE REUSE DATABASE "ORA9I" RESETLOGS FORCE LOGGING ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 10
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 '/SERVER/ora9/oradata/ora9i/redo01.log' SIZE 100M,
GROUP 2 '/SERVER/ora9/oradata/ora9i/redo02.log' SIZE 100M,
GROUP 3 '/SERVER/ora9/oradata/ora9i/redo03.log' SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'/SERVER/ora9/oradata/ora9i/system01.dbf',
'/SERVER/ora9/oradata/ora9i/undotbs01.dbf',
'/SERVER/ora9/oradata/ora9i/cwmlite01.dbf',
'/SERVER/ora9/oradata/ora9i/drsys01.dbf',
'/SERVER/ora9/oradata/ora9i/example01.dbf',
'/SERVER/ora9/oradata/ora9i/indx01.dbf',
'/SERVER/ora9/oradata/ora9i/odm01.dbf',
'/SERVER/ora9/oradata/ora9i/tools01.dbf',
'/SERVER/ora9/oradata/ora9i/user01.dbf',
'/SERVER/ora9/oradata/ora9i/xdb01.dbf',
'/SERVER/ora9/oradata/ora9i/data01.dbf',
'/SERVER/ora9/oradata/ora9i/chxi.dbf'
CHARACTER SET ZHS16GBK
;

在這裡要特別提出的是,
1)在CREATE CONTROLFILE REUSE DATABASE "ORA9I" RESETLOGS FORCE LOGGING ARCHIVELOG中間的RESETLOGS, 一定要改成NORESETLOGS,不然日誌的序列就亂了。也備庫的同步就會出現麻煩。

2)更改MAXLOGFILES 10


2,在主庫重建控制檔案

SQL> shutdown immediate;

SQL> @recreatectl.sh

控制檔案已建立.

SQL> shutdown immediate;

SQL> startup
資料庫重起成功,並確認REDO LOG的SEQUENCE有沒有被RESET:

SQL> select group#,sequence#,status from v$Log;

GROUP# SEQUENCE# STATUS
---------- ---------- ----------------
1 67 ACTIVE
2 66 INACTIVE
3 68 CURRENT

3,為備庫重建控制檔案
在主庫上執行:
SQL> alter database create standby controlfile as ‘控制檔名和路徑’
並傳送到備份機上。
關閉備庫,並用新的控制檔案覆蓋原來的控制檔案(注意備份舊的控制檔案);

4,重起備庫
SQL> startup nomount;
SQL> alter database mount standby database;
alter database mount standby database
*
ERROR at line 1:
ORA-01991: invalid password file '/SERVER/ora9/product/9.2/dbs/orapwora9i'

提示密碼檔案也失效了。
解決:從主庫再傳一份過來,覆蓋。
重啟備庫:
SQL> startup nomount;
SQL> alter database mount standby database;
SQL> alter database recover managed standby database disconnect from session;
確認相關程式已經啟動:
SQL> select process,status from v$managed_standby;

PROCESS STATUS
------- ------------
ARCH CONNECTED
ARCH CONNECTED
MRP0 WAIT_FOR_LOG
RFS RECEIVING
RFS ATTACHED

5,驗證備庫工作正常:
在主庫作日誌切換。並看備庫是否接收正常。

SQL> alter system switch logfile;

檢視備庫是否接收到主庫的日誌並正確應用。
SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

6,繼續加REDO lOG GROUP
這裡因為控制檔案被重建過了,之前在備庫中建立成功的兩個REDO4,REDO5也已經被用了。在OS中刪除。
[oracle@ora9-2 ora9i]$ rm redo04.log redo05.log
SQL> alter database add standby logfile group 4 ('/SERVER/ora9/oradata/ora9i/redo04.log') size 100M;

Database altered.

SQL> alter database add standby logfile group 5('/SERVER/ora9/oradata/ora9i/redo05.log') size 100M;

Database altered.

SQL> alter database add standby logfile group 6('/SERVER/ora9/oradata/ora9i/redo06.log') size 100M;

Database altered.

SQL> alter database add standby logfile group 7('/SERVER/ora9/oradata/ora9i/redo07.log') size 100M;

Database altered.

7,特殊情況
如果不能正常傳輸切換之間產生的日誌,需要手動傳輸並註冊到備庫進行恢復:
SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE '/SERVER/ora9/primary-arc/ora9i_1_60.log';
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

8,結束

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/703656/viewspace-1001452/,如需轉載,請註明出處,否則將追究法律責任。

相關文章