Oracle 控制檔案的重建

kakaxi9521發表於2016-12-01
最近做了一次data guard 備庫的備份和恢復,在恢復完資料檔案以後,用recover database using backup controlfile的時候有報錯,報控制檔案為備庫的控制檔案,無法進行日誌的recover。
在這樣的情況下我選擇了重建控制檔案。
1.建立控制檔案的trace檔案。
SQL> alter database backup controlfile to trace as '/home/oracle/crontol_trace1116.trc';

2. 將trace檔案down到本地,使用UE進行編輯,編輯後留下以下資訊。

--     Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- WARNING! The current control file needs to be checked against
-- the datafiles to insure it contains the correct files. The
-- commands printed here may be missing log and/or data files.
-- Another report should be made after the database has been
-- successfully opened.

-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "XXXXX" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 5840
LOGFILE
  GROUP 1 '+DATA/xxxxx/onlinelog/group_1.273.926696715'  SIZE 500M BLOCKSIZE 512,
  GROUP 2 '+DATA/xxxxx/onlinelog/group_2.274.926696717'  SIZE 500M BLOCKSIZE 512,
  GROUP 5 '+DATA/xxxxx/onlinelog/group_5.277.926696723'  SIZE 500M BLOCKSIZE 512,
  GROUP 6 '+DATA/xxxxx/onlinelog/group_6.278.926696725'  SIZE 500M BLOCKSIZE 512
-- STANDBY LOGFILE
--   GROUP 70 '+FRA/xxxxxdr/onlinelog/group_70.317.926718839'  SIZE 500M BLOCKSIZE 512,
--   GROUP 73 '+FRA/xxxxxdr/onlinelog/group_73.320.926718843'  SIZE 500M BLOCKSIZE 512
DATAFILE
  '+DATA/xxxxx/datafile/system.289.928015019',
  '+DATA/xxxxx/datafile/sysaux.285.928015017',
  '+DATA/xxxxx/datafile/undotbs1.276.928015009',
  '+DATA/xxxxx/datafile/users.287.928015017',
  '+DATA/xxxxx/datafile/undotbs2.275.928015009',
  '+DATA/xxxxx/datafile/xxxxx_data.277.928015011',
  '+DATA/xxxxx/datafile/xxxxx_data.278.928015011',
  '+DATA/xxxxx/datafile/xxxxx_data.279.928015011',
  '+DATA/xxxxx/datafile/xxxxx_data.280.928015011',
  '+DATA/xxxxx/datafile/xxxxx_index.288.928015017',
  '+DATA/xxxxx/datafile/xxxxx_data.281.928015013',
  '+DATA/xxxxx/datafile/xxxxx_data.282.928015013',
  '+DATA/xxxxx/datafile/xxxxx_data.283.928015015',
  '+DATA/xxxxx/datafile/xxxxx_data.284.928015015',
  '+DATA/xxxxx/datafile/xxxxx_data.286.928015017',
  '+DATA/xxxxx/datafile/xxxxx_data.290.928015019'
CHARACTER SET AL32UTF8
;

-- Configure RMAN configuration record 1
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('SNAPSHOT CONTROLFILE NAME','TO ''+fra/xxxxx/controlfile_snapshot/snapshot_xxxxx.f''');
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/ulic/backup/xxxxx/1_1_824297850.arc';
-- ALTER DATABASE REGISTER LOGFILE '/ulic/backup/xxxxx/1_1_895428295.arc';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE

-- Create log files for threads other than thread one.
ALTER DATABASE ADD LOGFILE THREAD 2
  GROUP 3 '+DATA/xxxxxdr/onlinelog/group_3.275.926696719' SIZE 500M BLOCKSIZE 512 REUSE,
  GROUP 4 '+DATA/xxxxxdr/onlinelog/group_4.276.926696721' SIZE 500M BLOCKSIZE 512 REUSE,
  GROUP 7 '+DATA/xxxxxdr/onlinelog/group_7.279.926696725' SIZE 500M BLOCKSIZE 512 REUSE,
  GROUP 8 '+DATA/xxxxxdr/onlinelog/group_8.280.926696727' SIZE 500M BLOCKSIZE 512 REUSE;

-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '+DATA/xxxxx/tempfile/temp.265.895428301' REUSE;
-- End of tempfile additions.

5. 透過vi編輯器將以上資訊編輯到檔案中。

6. 在sql中透過SQL>@create_controlfile.sql來建立控制檔案。

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

相關文章