ITPub博客

首页 > 数据库 > Oracle > Control Files

Control Files

原创 Oracle 作者:caisanpx 时间:2014-03-25 10:45:49 0 删除 编辑

一、Multiplex Control Files on Different Disks


Every Oracle Database should have at least two control files, each stored on a different physical disk. If a control file is damaged due to a disk failure, the associated instance must be shut down. Once the disk drive is repaired, the damaged control file can be restored using the intact copy of the control file from the other disk and the instance can be restarted. In this case, no media recovery is required.

The behavior of multiplexed control files is this:

  • The database writes to all filenames listed for the initialization parameter CONTROL_FILES in the database initialization parameter file.

  • The database reads only the first file listed in the CONTROL_FILES parameter during database operation.

  • If any of the control files become unavailable during database operation, the instance becomes inoperable and should be aborted.

    Note:

    Oracle strongly recommends that your database has a minimum of two control files and that they are located on separate physical disks.

One way to multiplex control files is to store a control file copy on every disk drive that stores members of redo log groups, if the redo log is multiplexed. By storing control files in these locations, you minimize the risk that all control files and all groups of the redo log will be lost in a single disk failure.


二、Steps for Creating New Control Files

Complete the following steps to create a new control file.

  1. 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 comprise the SYSTEM tablespace, you might not be able to recover the database.

  2. 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. 3.Back up all datafiles and redo log files of the database.

  4. 4.Start up a new instance, but do not mount or open the database:

    STARTUP NOMOUNT
    
  5. 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. 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. 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. 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 User's Guide for information about recovering your database and methods of recovering a lost control file
  9. 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.


三、Back Up Control Files

It is very important that you back up your control files. This is true initially, and every time you change the physical structure of your database. Such structural changes include:

  • Adding, dropping, or renaming datafiles

  • Adding or dropping a tablespace, or altering the read/write state of the tablespace

  • Adding or dropping redo log files or groups


    Use the ALTER DATABASE BACKUP CONTROLFILE statement to back up your control files. You have two options:

    • Back up the control file to a binary file (duplicate of existing control file) using the following statement:

      ALTER DATABASE BACKUP CONTROLFILE TO '/oracle/backup/control.bkp';
      
    • Produce SQL statements that can later be used to re-create your control file:

      ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
      

      This command writes a SQL script to a trace file where it can be captured and edited to reproduce the control file. View the alert log to determine the name and location of the trace file.



四、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.



五 、Handling Errors During CREATE CONTROLFILE

If Oracle Database sends you an error (usually error ORA-01173, ORA-01176, ORA-01177, ORA-01215, or ORA-01216) when you attempt to mount and open the database after creating a new control file, the most likely cause is that you omitted a file from the CREATE CONTROLFILE statement or included one that should not have been listed. In this case, you should restore the files you backed up in step 3 and repeat the procedure from step 4, using the correct filenames.




六、Control Files Data Dictionary Views

The following views display information about control files:

View Description
V$DATABASE Displays database information from the control file
V$CONTROLFILE Lists the names of control files
V$CONTROLFILE_RECORD_SECTION Displays information about control file record sections
V$PARAMETER Displays the names of control files as specified in the CONTROL_FILES initialization parameter



more details:http://docs.oracle.com/cd/E11882_01/server.112/e25494/control.htm#ADMIN006

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26844646/viewspace-1128950/,如需转载,请注明出处,否则将追究法律责任。

下一篇: Managing Redo File
请登录后发表评论 登录
全部评论

注册时间:2012-04-12

  • 博文量
    165
  • 访问量
    444732