重建控制檔案

Diy_os發表於2015-04-14
重建控制檔案是不得已之選,如果沒有備份和控制檔案冗餘的情況下,但是我們仍需要一些資料庫資訊,下面簡單的介紹一下過程:
把資料庫啟動到mount:
SQL> startup mount;
ORACLE 例程已經啟動。


Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             327158144 bytes
Database Buffers           88080384 bytes
Redo Buffers                6094848 bytes
資料庫裝載完畢。
SQL> alter database backup controlfile to trace;


資料庫已更改。

我們開啟trace檔案,裡面有我們重建控制檔案的指令碼:
CREATE CONTROLFILE REUSE DATABASE "ORCL3939" NORESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/orcl3939/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/orcl3939/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/orcl3939/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/u01/app/oracle/oradata/orcl3939/system01.dbf',
  '/u01/app/oracle/oradata/orcl3939/sysaux01.dbf',
  '/u01/app/oracle/oradata/orcl3939/undotbs01.dbf',
  '/u01/app/oracle/oradata/orcl3939/users01.dbf',
  '/u01/app/oracle/oradata/orcl3939/example01.dbf',
  '/u01/app/oracle/oradata/orcl3939/wang.dbf',
  '/u01/app/oracle/oradata/orcl3939/chao.dbf',
  '/u01/app/oracle/oradata/orcl3939/big_file',
  '/u01/app/oracle/oradata/orcl3939/undo_w.dbf',
  '/u01/app/oracle/oradata/orcl3939/wang1.dbf',
  '/u01/app/oracle/oradata/orcl3939/a.dbf',
  '/u01/app/oracle/oradata/orcl3939/v.dbf'
CHARACTER SET AL32UTF8
;
透過此指令碼,我們可以重建控制檔案:

SQL> startup nomount;
ORACLE 例程已經啟動。


Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             327158144 bytes
Database Buffers           88080384 bytes
Redo Buffers                6094848 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "ORCL3939" NORESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/orcl3939/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/orcl3939/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/orcl3939/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/u01/app/oracle/oradata/orcl3939/system01.dbf',
  '/u01/app/oracle/oradata/orcl3939/sysaux01.dbf',
  '/u01/app/oracle/oradata/orcl3939/undotbs01.dbf',
  '/u01/app/oracle/oradata/orcl3939/users01.dbf',
  '/u01/app/oracle/oradata/orcl3939/example01.dbf',
  '/u01/app/oracle/oradata/orcl3939/wang.dbf',
  '/u01/app/oracle/oradata/orcl3939/chao.dbf',
  '/u01/app/oracle/oradata/orcl3939/big_file',
  '/u01/app/oracle/oradata/orcl3939/undo_w.dbf',
  '/u01/app/oracle/oradata/orcl3939/wang1.dbf',
  '/u01/app/oracle/oradata/orcl3939/a.dbf',
  '/u01/app/oracle/oradata/orcl3939/v.dbf'
CHARACTER SET AL32UTF8
接下來,我們恢復資料庫:
SQL>recover database using backup controlfile;這個過程會用到歸檔日誌,用完歸檔日誌,會用重做日誌檔案
SQL>recover database using backup controlfile;
然後我們開啟資料庫:
SQL>alter database open resetlogs;
Database altered;
因為控制檔案中沒有包括臨時表空間,我們可以透過手工新增臨時表空間:
alter  tablespace temp add tempfile 'XXXXXXXX' size xx reuse autoextend on next xxx;

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

相關文章