BIT352 ยท 0 ยท 10 marks
What is control file? What are the contents of control file? Explain the procedure of multiplexing control file using pfile.
What is control file? What are the contents of control file? Explain the procedure of multiplexing control file using pfile.[10]
Quick answer
A control file is a small binary file that is essential to the Oracle database. It records the physical structure of the database and is read by Oracle at database startup. The control file must be available and accessible whenever the database is mounted or opened.
Control File in Oracle Database
What is a Control File?
Key characteristics:
- It is a binary file (cannot be edited manually)
- It is created automatically when the database is created
- Oracle must have access to the control file to mount and open the database
- It is continuously updated by Oracle during database operation
Contents of a Control File
The control file stores critical information about the database, including:
- Database Name - The name of the database as specified during creation
- Database Identifier (DBID) - A unique identifier for the database
- Database Creation Timestamp - Date and time when the database was created
- Tablespace Names - Names of all tablespaces in the database
- Names and Locations of Datafiles - Physical paths of all datafiles
- Names and Locations of Redo Log Files - Physical paths of all online redo log files
- Current Log Sequence Number - The sequence number of the current redo log
- Checkpoint Information - Details about the most recent checkpoint
- Begin and End of Undo Segments - Information about undo/rollback segments
- RMAN Backup Information - Details of RMAN backups (if RMAN is used)
- Archive Log History - Information about archived redo log files
- SCN (System Change Number) - The current SCN of the database
Multiplexing Control File Using PFILE
Multiplexing means maintaining multiple copies of the control file on different disk locations. This protects against loss of the control file due to disk failure.
Why Multiplex?
- If the single control file is lost or corrupted, the database cannot be started
- Oracle recommends keeping 2 to 3 copies of the control file on separate disks
Procedure to Multiplex Control File Using PFILE
Step 1: Check the Current Control File Location
Log in to SQL*Plus as SYSDBA and check the current control file locations:
SQL> SHOW PARAMETER CONTROL_FILES;
or
SQL> SELECT NAME FROM V$CONTROLFILE;
This shows the current path(s) of the control file(s).
Step 2: Shut Down the Database
Shut down the database cleanly before making changes:
SQL> SHUTDOWN IMMEDIATE;
Step 3: Locate and Edit the PFILE
The PFILE (Parameter File) is a text-based initialization file, typically located at:
$ORACLE_HOME/dbs/initSID.ora (Linux/Unix)
%ORACLE_HOME%\database\initSID.ora (Windows)
Open the PFILE using a text editor and find the CONTROL_FILES parameter. It may look like:
control_files = ('/u01/oradata/orcl/control01.ctl')
Modify it to include the new (additional) control file location:
control_files = ('/u01/oradata/orcl/control01.ctl',
'/u02/oradata/orcl/control02.ctl',
'/u03/oradata/orcl/control03.ctl')
Save and close the PFILE.
Step 4: Copy the Existing Control File to New Locations
Using the operating system commands, copy the existing control file to the new paths specified in the PFILE:
On Linux/Unix:
$ cp /u01/oradata/orcl/control01.ctl /u02/oradata/orcl/control02.ctl
$ cp /u01/oradata/orcl/control01.ctl /u03/oradata/orcl/control03.ctl
On Windows:
COPY C:\oradata\orcl\control01.ctl D:\oradata\orcl\control02.ctl
Note: This copy must be done while the database is shut down, because the control file is a binary file and must be consistent.
Step 5: Start the Database Using the Modified PFILE
Start the database using the PFILE:
SQL> STARTUP PFILE='/u01/app/oracle/product/19c/dbs/initorcl.ora';
Step 6: Verify the Multiplexed Control Files
After startup, verify that Oracle is now using all the control file copies:
SQL> SELECT NAME FROM V$CONTROLFILE;
Expected Output:
NAME
------------------------------------------
/u01/oradata/orcl/control01.ctl
/u02/oradata/orcl/control02.ctl
/u03/oradata/orcl/control03.ctl
Step 7: (Optional) Create SPFILE from PFILE
If the database normally uses an SPFILE, recreate it from the updated PFILE:
SQL> CREATE SPFILE FROM PFILE='/u01/app/oracle/product/19c/dbs/initorcl.ora';
Then restart the database normally:
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;
Summary Table
| Step | Action |
|---|---|
| 1 | Check current control file locations |
| 2 | Shut down the database |
| 3 | Edit PFILE to add new control file paths |
| 4 | Copy control file to new OS locations |
| 5 | Start database using PFILE |
| 6 | Verify multiplexed control files |
| 7 | Optionally recreate SPFILE |
Best Practice: Always store control file copies on separate physical disks to ensure protection against disk failure.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.