控制檔案的恢復方法(四)

kuqlan發表於2012-06-16

控制檔案的通常恢復方法有:
1、從控制檔案自動或二進位制備份中恢復

2、從控制檔案快照備份中恢復

3、控制檔案trace檔案備份中恢復

4Oracle自動生成的控制檔案指令碼恢復

如下對相關的步驟及語法進行介紹:

4Oracle自動生成的控制檔案指令碼恢復

在搭建Oracle Data Guard環境時,primary在SWITCHOVER TO PHYSICAL STANDBY時會自動在udump目錄中產生一份trace,其中有重新建立控制檔案的指令碼。

如果單節點的(不是RAC)的災備系統則,關閉備庫後,按前面介紹的方法恢復即可;

[@more@]

如果主庫為RAC環境,則按如下步驟進行:

1.將另一個節點叢集服務停止。

$ srvctl stop nodeapps -n testdb2

2.修改cluster_database 引數(否則會報 ORA-12720 錯誤)。

SQL> alter system set cluster_database=FALSE scope=spfile sid='test2';

3.停庫。

SQL> shutdown immediate

4.nomount資料庫。

SQL> startup nomount

5.使用norestlog 版SQL重建控制檔案。

SQL>@createctlf.sql

6.恢復資料庫(如確實需要執行恢復操作)後開啟主庫。

SQL> recover database;

SQL> alter database open;

另外在官方文件也提到了手工建立新的控制方法及說明,如下摘取了關鍵內容:

The CREATE CONTROLFILE Statement

You can create a new control file for a database using the CREATE CONTROLFILE statement. The following statement creates a new control file for the prod database (a database that formerly used a different database name):

CREATE CONTROLFILE
SET DATABASE prod
LOGFILE GROUP 1 ('/u01/oracle/prod/redo01_01.log',
'/u01/oracle/prod/redo01_02.log'),
GROUP 2 ('/u01/oracle/prod/redo02_01.log',
'/u01/oracle/prod/redo02_02.log'),
GROUP 3 ('/u01/oracle/prod/redo03_01.log',
'/u01/oracle/prod/redo03_02.log')
RESETLOGS
DATAFILE '/u01/oracle/prod/system01.dbf' SIZE 3M,
'/u01/oracle/prod/rbs01.dbs' SIZE 5M,
'/u01/oracle/prod/users01.dbs' SIZE 5M,
'/u01/oracle/prod/temp01.dbs' SIZE 5M
MAXLOGFILES 50
MAXLOGMEMBERS 3
MAXLOGHISTORY 400
MAXDATAFILES 200
MAXINSTANCES 6
ARCHIVELOG;

Cautions:

  • The CREATE CONTROLFILE statement can potentially damage specified datafiles and redo log files. Omitting a filename can cause loss of the data in that file, or loss of access to the entire database. Use caution when issuing this statement and be sure to follow the instructions in .
  • If the database had forced logging enabled before creating the new control file, and you want it to continue to be enabled, then you must specify the FORCE LOGGING clause in the CREATE CONTROLFILE statement. See .

See Also:

describes the complete syntax of the CREATE CONTROLFILE statement

Steps for Creating New Control Files

Complete the following steps to create a new control file.

  1. Make a list of all datafiles and redo log files of the database.
    If you follow recommendations for control file backups as discussed in
    , you will already have a list of datafiles and redo log files that reflect the current structure of the database. However, if you have no such list, executing the following statements will produce one.
    SELECT MEMBER FROM V$LOGFILE;
    SELECT NAME FROM V$DATAFILE;
    SELECT VALUE FROM V$PARAMETER WHERE NAME = 'control_files';

    If you have no such lists and your control file has been damaged so that the database cannot be opened, try to locate all of the datafiles and redo log files that constitute the database. Any files not specified in step
    are not recoverable once a new control file has been created. Moreover, if you omit any of the files that make up the SYSTEM tablespace, you might not be able to recover the database.
  2. Shut down the database.
    If the database is open, shut down the database normally if possible. Use the IMMEDIATE or ABORT clauses only as a last resort.
  3. Back up all datafiles and redo log files of the database.
  4. Start up a new instance, but do not mount or open the database:
    STARTUP NOMOUNT
  5. Create a new control file for the database using the CREATE CONTROLFILE statement.
    When creating a new control file, specify the RESETLOGS clause if you have lost any redo log groups in addition to control files. In this case, you will need to recover from the loss of the redo logs (step
    ). You must specify the RESETLOGS clause if you have renamed the database. Otherwise, select the NORESETLOGS clause.
  6. Store a backup of the new control file on an offline storage device. See for instructions for creating a backup.
  7. Edit the CONTROL_FILES initialization parameter for the database to indicate all of the control files now part of your database as created in step (not including the backup control file). If you are renaming the database, edit the DB_NAME parameter in your instance parameter file to specify the new name.
  8. Recover the database if necessary. If you are not recovering the database, skip to step .
    If you are creating the control file as part of recovery, recover the database. If the new control file was created using the NORESETLOGS clause (step
    ), you can recover the database with complete, closed database recovery.
    If the new control file was created using the RESETLOGS clause, you must specify USING BACKUP CONTROL FILE. If you have lost online or archived redo logs or datafiles, use the procedures for recovering those files.
    See Also:
    and for information about recovering your database and methods of recovering a lost control file
  9. Open the database using one of the following methods:
  • If you did not perform recovery, or you performed complete, closed database recovery in step , open the database normally.
    ALTER DATABASE OPEN;
  • If you specified RESETLOGS when creating the control file, use the ALTER DATABASE statement, indicating RESETLOGS.
    ALTER DATABASE OPEN RESETLOGS;

The database is now open and available for use.

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

相關文章