ITPub博客

首页 > 数据库 > Oracle > 控制文件的恢复方法(四)

控制文件的恢复方法(四)

原创 Oracle 作者:kuqlan 时间:2012-06-16 22:59:56 0 删除 编辑

控制文件的通常恢复方法有:
1、从控制文件自动或二进制备份中恢复

2、从控制文件快照备份中恢复

3、控制文件trace文件备份中恢复

4、Oracle自动生成的控制文件脚本恢复

如下对相关的步骤及语法进行介绍:

4、Oracle自动生成的控制文件脚本恢复

在搭建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 "Steps for Creating New Control Files".
  • 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 "Specifying FORCE LOGGING Mode".

See Also:

Oracle Database SQL Reference 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
    "Backing Up Control Files" , 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
    5 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
    8). 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 "Backing Up Control Files" 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 5 (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 9.
    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
    5), 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:
    Oracle Database Backup and Recovery Basics and Oracle Database Backup and Recovery Advanced User's Guide 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 8, 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博客 ” ,链接:https://blog.itpub.net/18841027/viewspace-1058557/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle技术爱好者,Oracle10g OCM,网名 KUQLAN ,具有7的年Oracle数据库管理实践,曾经参加过BOSS、ERP、云计算(OpenStack+kvm)等项目的一线工作。以前写博客是为了自己,而现在是为了自己和别人。因为领会了帮助别人和分享、沉淀和积累会创造快乐和价值...

注册时间:2009-01-26

  • 博文量
    183
  • 访问量
    1681007