The role of the control file to the Oralce database is similar to that of the Registry in the Microsoft operating system. The control file is a relatively small binary file that records the structure information of the database. If the Database Control File Sun Hua occurs, Oracle cannot start normally. Generally, a control file is automatically created when a database is created. When the database structure changes, the content of the automatic file is automatically modified.
However, when the control file is damaged due to some database faults, the database administrator may need to manually re-create the control file to solve the database startup failure. Here I will talk about the policies for manually creating control files. We hope to help you solve database faults caused by Control File Corruption.
1. Under what circumstances should I manually create a new control file?
Generally, the system automatically creates a control file during database creation. However, in some special cases, the database administrator needs to manually create a new control file. As far as I know, there are two main situations.
First, you want to change the permanent settings of a database parameter. When creating a database, the database administrator needs to set some permanent parameters, such as the database name. Sometimes in some special circumstances, you need to modify these permanent parameters. For example, with the expansion of the enterprise scale, a database server can no longer meet the daily work needs of the enterprise. Therefore, the database administrator decided to use a distributed environment to improve the database performance. However, since this situation was not taken into account when you first created the database, it is easier to name the database. Now you need to create multiple databases. in order to unify the naming policies of each database, the Administrator may need to change the database name to comply with this naming rule. In this case, the database administrator must manually create a new control file to change the database name.
Second, the control files of all databases are permanently damaged. Generally, when the database is in Archivelog mode, the ARCH process automatically modifies the control file with information such as the archive log file name and log serial number. When the Administrator uses RMAN to perform the backup operation, the backup information of RMAN is also recorded in the control file. Therefore, if the control file is permanently damaged, the impact on the database is fatal. At this time, the database administrator is negligent and does not back up the database control file (or the backup file is earlier), so the database administrator has to manually create a new control file.
2. How to Create a control file?
It is troublesome to manually create new control files. However, if you follow the steps below, the database administrator can still create an intact control file.
Step 1: create a list of all data files and redo log files of the database.
Because the database must have relevant information about the data file when it starts. To create a new control file, the database administrator must first collect the list of all database data files and redo log files. This list can be obtained from two places. First, if the control file is backed up, you can obtain information about the data file and the redo log file from the backup control file. If there is no backup control file or the backup control file is corrupted, You can query related information from the dynamic performance view. For example, the query statement select name from v $ DATEFILE is used to query information of all data files. A prerequisite is that the latest backup file or database of the control file can still be started normally. That is to say, if you need to change the database's permanent parameters, you can use this method to obtain the required information.
However, if the database cannot be started at this time and the information cannot be found, or the control file has been severely damaged and there is no suitable backup control file, the above methods are not applicable. In this case, the database administrator only needs to manually locate all data files and redo log files that constitute the database. That is to say, the database administrator should sort these records according to the notes in daily work. Under normal circumstances, when I create a data file, there will be a written record. In the event of this unexpected situation, these written records will play a role.
Note that the data files collected by the database administrator are incomplete at this time, and errors will occur when the database is started. In this case, the administrator needs to find the cause based on the error information provided by the system. After creating a new control file and using it to open the database, Oracle checks the data dictionary and control file content. If the data dictionary contains a data file, but the control file does not list the data file, the Oracle database reports an error. Oracle will create a placeholder entry named Missingnnn in the new control file. The final NNN is the file number in decimal format. In this case, the database administrator can use this information to determine whether necessary data files are missing. After finding the data file, you can modify this value so that the database can find the corresponding real data file.
Step 2: Shut down the database.
If the database is still in the starting status, you need to shut down the database first. When you disable it, if you can disable it in normal mode, you 'd better disable it in normal mode. Other close modes are the last resort. Disabling in normal mode can reduce possible problems during database restart.
In addition, to ensure security, it is best to back up all data files, redo log files, and parameter files in the database to other places after the database is closed. This is mainly to cause irreparable losses to the database due to carelessness. Although this is not necessary, I strongly recommend that you do this.
Step 3: Create a new control file.
After the database administrator backs up all the data files, redo log files, and parameter files, a new routine needs to be started. But do not load or open the database. That is to say, the commands such as startup nomount. Database startup involves three steps: startup routine, Database loading, and database opening. At this time, the database administrator must note that only one process can be started without loading the database or opening the database. Otherwise, the control file cannot be created successfully.
After the routine is started, the database administrator must use the Create Controfile statement to Create a new control file. If some redo log groups are lost in addition to the control file, you also need to use the Resetlogs parameter. That is to say, You need to restore the lost redo log. In addition, unlike the damage caused by Database Control files, this parameter is also required if you only need to change the database name. This control file has not been fully completed yet. Because the control file does not have initialization parameters yet. The Database Administrator also needs to manually modify the initialization parameters in the control file. In order to prevent subsequent work from re-damaging the new control file, we recommend that you back up the control file before preparing the control file's initialization parameters. In this case, you do not need to repeat the initialization parameters of the control file. You only need to restore the newly created control file.