Oracle重建控制檔案 - Rebuild controlfile

來源:互聯網
上載者:User

Oracle重建控制檔案 - Rebuild controlfile

重建控制檔案時DBA需要知道,但是也許整個職業生涯都不會再生產系統上遇見。

首先強調,備份是最安全,快捷,有效恢複方式,一個DBA,如果沒有規劃好有效備份,終有一天,他會被噩夢驚醒。

夢醒之後,就是無奈的,繁雜的手工恢複。而且,恢複到什麼程度,就要看天,看命,反正不能看自己了,因為沒有備份,你已經將主動權完全交個別人。這裡就記錄一下controlfile的重建

在其他正常的資料庫上建立controlfile trace

SQL> alter database backup controlfile to trace;
指定trace檔案的產生路徑
SQL> alter database backup controlfile to trace as '/tmp/controlfile.trc';      trace 檔案路徑在user_dump_dest下

SQL> show parameter user_dump_dest 

NAME            TYPE        VALUE 

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

user_dump_dest  string      /home/Oracle/admin/R10105/udump/

After navigating to the directory locate the latest trace file by date/time by issuing:  ls -ltr.

% cd /home/oracle/admin/R10105/udump/ 

% ls -ltr

一個完整的trace請參考附件

    你可以修改trace檔案的路徑等具體參數值,並提取其中的建立指令碼 

STARTUP NOMOUNT

CREATE CONTROLFILE REUSE DATABASE "R10105" NORESETLOGS  ARCHIVELOG

    MAXLOGFILES 16

    MAXLOGMEMBERS 3

    MAXDATAFILES 100

    MAXINSTANCES 8

    MAXLOGHISTORY 454

LOGFILE

  GROUP 1 '/opt/oracle/oradata/R10105/redo01.log'  SIZE 10M,

  GROUP 2 '/opt/oracle/oradata/R10105/redo02.log'  SIZE 10M,

  GROUP 3 '/opt/oracle/oradata/R10105/redo03.log'  SIZE 10M

-- STANDBY LOGFILE

DATAFILE

  '/opt/oracle/oradata/R10105/system01.dbf',

  '/opt/oracle/oradata/R10105/undotbs01.dbf',

  '/opt/oracle/oradata/R10105/sysaux01.dbf',

  '/opt/oracle/oradata/R10105/users01.dbf',

  '/opt/oracle/oradata/R10105/example01.dbf'

CHARACTER SET AL32UTF8

;

註冊archivelog

-- ALTER DATABASE REGISTER LOGFILE '/home/oracle/flash_recovery_area/R10105/archivelog/2012_06_15/o1_mf_1_1_%u_.arc';

-- ALTER DATABASE REGISTER LOGFILE '/home/oracle/flash_recovery_area/R10105/archivelog/2012_06_15/o1_mf_1_1_%u_.arc';

-- Recovery is required if any of the datafiles are restored backups,

-- or if the last shutdown was not normal or immediate.

RECOVER DATABASE

-- All logs need archiving and a log switch is needed.

ALTER SYSTEM ARCHIVE LOG ALL;

-- Database can now be opened normally.

ALTER DATABASE OPEN;

-- Commands to add tempfiles to temporary tablespaces.

-- Online tempfiles have complete space information.

-- Other tempfiles may require adjustment.

ALTER TABLESPACE TEMP ADD TEMPFILE '/opt/oracle/oradata/R10105/temp01.dbf'

    SIZE 20971520  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;

-- End of tempfile additions.

--

其實重建控制檔案,就是相當於手動重建立庫,把現有的資料庫資源,逐一添加到controlfile中,最後註冊目前的archivelog檔案。

同時,重建controlfile分為NORESETLOGS和RESETLOGS兩種,根據需求選擇相應的指令碼。

最後的最後,這一切,都是噩夢,還是做好有效備份,有備無患,才是王道!!

附件:
Oracle重建控制檔案 - Rebuild controlfile 

https://www.bkjia.com/topicnews.aspx?tid=12

本文永久更新連結地址:https://www.bkjia.com/Linux/2018-03/151561.htm

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.