|Oracle8i Administrator's Guide
Release 2 (8.1.6)
This chapter explains how to create and maintain the control files for your database and includes the following topics:
Every Oracle database has a control file. A control files records the physical structure of the database and contains:
The control file of an Oracle database is created at the same time as the database. By default, at least one copy of the control file must be created during database creation. On some operating systems, Oracle creates multiple copies. You should create two or more copies of the control file during database creation. You might also need to create control files later, if you lose control files or want to change particular settings in the control files.
This section describes guidelines you can use to manage the control files for a database, and includes the following topics:
Assign control file names via the CONTROL_FILES initialization parameter in the database's initialization parameter file. CONTROL_FILES specifies one or more names of control files separated by commas. The instance startup procedure recognizes and opens all the listed files. The instance writes to and maintains all listed control files during database operation.
For a description of the CONTROL_FILES initialization parameter, see Oracle8i Reference.
Every Oracle database should have at least two control files, each stored on a different 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 an intact copy of the control file and the instance can be restarted; no media recovery is required.
The following describes the behavior of multiplexed control files:
The only disadvantage of having multiple control files is that all operations that update the control files (such as adding a datafile or checkpointing the database) can take slightly longer. However, this difference is usually insignificant (especially for operating systems that can perform multiple, concurrent writes) and does not justify using only a single control file.
Each copy of a control file should be stored on a different disk drive. Furthermore, a control file copy should be stored on every disk drive that stores members of online redo log groups, if the online redo log is multiplexed. By storing control files in these locations, you minimize the risk that all control files and all groups of the online redo log will be lost in a single disk failure.
The main determinants of a control file's size are the values set for the MAXDATAFILES, MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, and MAXINSTANCES parameters in the CREATE DATABASE statement that created the associated database. Increasing the values of these parameters increases the size of a control file of the associated database.
For the syntax of the CREATE DATABASE statement, see the Oracle8i SQL Reference.
This section describes ways to create control files, and includes the following topics:
You create the initial control files of an Oracle database by specifying one or more control filenames in the CONTROL_FILES initialization parameter in the initialization parameter file used during database creation. The filenames specified in CONTROL_FILES should be fully specified. Filename specification is operating system-specific.
If files with the specified names currently exist at the time of database creation, you must specify the CONTROLFILE REUSE parameter in the CREATE DATABASE statement, or else an error occurs. Also, if the size of the old control file differs from that of the new one, you cannot use the REUSE option. The size of the control file changes between some releases of Oracle, as well as when the number of files specified in the control file changes. Configuration parameters such as MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES, and MAXINSTANCES affect control file size.
If you do not specify files for CONTROL_FILES before database creation, Oracle creates a control file and uses a default filename. The default name is also operating system-specific.
You can subsequently change the value of the CONTROL_FILES initialization parameter to add more control files or to change the names or locations of existing control files.
You add a new control file by copying an existing file to a new location and adding the file's name to the list of control files.
Similarly, you rename an existing control file by copying the file to its new name or location, and changing the file's name in the control file list.
In both cases, to guarantee that control files do not change during the procedure, shut down the instance before copying the control file.
You can create a new control file for a database using the CREATE CONTROLFILE statement. This is necessary in the following situations:
For example, you might need to change a database's name if it conflicts with another database's name in a distributed environment. Or, as another example, you might need to change one of the previously mentioned parameters if the original setting is too low.
The following statement creates a new control file for the PROD database (formerly a database that used a different database name):
CREATE CONTROLFILE SET DATABASE prod LOGFILE GROUP 1 ('logfile1A', 'logfile1B') SIZE 50K, GROUP 2 ('logfile2A', 'logfile2B') SIZE 50K NORESETLOGS DATAFILE 'datafile1' SIZE 3M, 'datafile2' SIZE 5M MAXLOGFILES 50 MAXLOGMEMBERS 3 MAXDATAFILES 200 MAXINSTANCES 6 ARCHIVELOG;
The CREATE CONTROLFILE statement can potentially damage specified datafiles and online redo log files; omitting a filename can cause loss of the data in that file, or loss of access to the entire database. Employ caution when using this statement and be sure to follow the steps in the next section.
FFor information on changing the global database name and the DB_DOMAIN initialization parameter, see Oracle8i Distributed Database Systems.
This section provides step-by-step instructions for creating new control files.
If you followed the recommendations for database backups, you should already have a list of datafiles and online redo log files that reflect the current structure of the database.
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 online 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.
If the database is open, shut down the database with normal priority, if possible. Use the IMMEDIATE or ABORT options only as a last resort.
When creating the new control file, select the RESETLOGS option if you have lost any online redo log groups in addition to the control files. In this case, you will need to recover from the loss of the redo logs (Step 8). You must also specify the RESETLOGS option if you have renamed the database. Otherwise, select the NORESETLOGS option.
Edit the initialization parameter file of the database to indicate all of the control files created in Step 5 and Step 6 (not including the backup control file) in the CONTROL_FILES parameter. If you are renaming the database, edit the DB_NAME parameter to specify the new name.
If you are creating the control file as part of recovery, recover the database. If the new control file was created using the NORESETLOGS option (Step 5), you can recover the database with complete, closed database recovery.
If the new control file was created using the RESETLOGS option, 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.
Open the database using one of the following methods:
The database is now open and available for use.
See the Oracle8i Backup and Recovery Guide for more information about:
After issuing the CREATE CONTROLFILE statement, you may encounter some common errors. This section describes the most common control file usage errors, and includes the following topics:
After creating a new control file and using it to open the database, check the alert log to see if Oracle has detected inconsistencies between the data dictionary and the control file, such as a datafile that the data dictionary includes but the control file does not list.
If a datafile exists in the data dictionary but not in the new control file, Oracle creates a placeholder entry in the control file under the name MISSINGnnnn (where nnnn is the file number in decimal). MISSINGnnnn is flagged in the control file as being offline and requiring media recovery.
In the following two cases only, the actual datafile corresponding to MISSINGnnnn can be made accessible by renaming MISSINGnnnn to point to it.
The new control file was created using the CREATE CONTROLFILE statement with the NORESETLOGS option, thus allowing the database to be opened without using the RESETLOGS option. This would be possible only if all online redo logs are available.
It was necessary to use the RESETLOGS option of the CREATE CONTROLFILE statement, thus forcing the database to be opened using the RESETLOGS option, but the actual datafile corresponding to MISSINGnnnn was read-only or offline normal.
If, on the other hand, it was necessary to open the database using the RESETLOGS option, and MISSINGnnnn corresponds to a datafile that was not read-only or offline normal, then the rename operation cannot be used to make the datafile accessible (since the datafile requires media recovery that is precluded by the results of RESETLOGS). In this case, the tablespace containing the datafile must be dropped.
In contrast, if a datafile indicated in the control file is not present in the data dictionary, Oracle removes references to it from the new control file. In both cases, Oracle includes an explanatory message in the alert log to let you know what it found.
If Oracle 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.
You can drop control files from the database. For example, you might want to do so if the location of a control file is inappropriate. Remember that the database must have at least two control files at all times.