Backup Options   «Prev  Next»

Lesson 5Reconstructing a lost or damaged control file
ObjectiveChoose an appropriate control-file recovery method and explain how to restore a backup or re-create a control file from verified trace SQL.

Recover or Re-create a Lost Control File in Oracle 26ai

A lost control file does not automatically require manual reconstruction. First determine whether a usable current copy survives. If none survives, look for a suitable binary backup. Re-creating the control file from trace SQL is a separate recovery path that requires an accurate description of the database and careful handling of its files.

This lesson explains those choices for Oracle AI Database 26ai. The examples use a single-instance container database (CDB) in ARCHIVELOG mode. They assume usable parameter configuration and available datafiles and redo unless otherwise stated. If the incident also damaged the SPFILE, datafiles, or required redo, include those failures in the recovery plan.

The operating sequence matters: establish a usable control file, mount the database, complete the required recovery, and then open appropriately. Opening first and attempting media recovery afterward is not the procedure taught here.

What the Control File Provides

The control file is a binary record of database identity and physical structure. It includes datafile and redo information, checkpoint information, and records used by RMAN. A CDB uses a common control-file set for its root and PDBs; each PDB does not have a separate control file.

The instance reads its initialization configuration before mounting the database. Consequently, it can reach NOMOUNT even when no control file is usable. Mounting requires a usable control file. A failure during STARTUP therefore does not establish that the database is mounted; inspect the actual instance state.

Distinguish three resources: a current multiplexed copy maintained during database operation, a binary backup representing an earlier state, and a trace containing SQL for reconstruction. A trace cannot be mounted as a control file. These resources have different recovery implications, so record exactly which one you intend to use.

Diagnose the Failure and Choose a Path

A control-file error can result from unavailable storage, permissions, an incorrect path, or corruption. Examine the error stack and alert log, and investigate the underlying storage problem. Check every configured copy before concluding that all current copies are lost.

From an authorized SQL*Plus session, the following checks help identify the configured locations and current instance state, including when the instance is in NOMOUNT:

SHOW PARAMETER control_files

SELECT instance_name, status
FROM v$instance;

Structural views such as V$DATAFILE are not a substitute for a saved inventory when the database cannot mount. At that point, work from preserved trace output, configuration records, backup metadata, and corroborating diagnostics.

Choose the control-file recovery path
Available resourceStarting actionRecovery implications
Usable current copyReplace the failed copy from the surviving current copy with the instance stopped.Replacement alone does not require media recovery or RESETLOGS.
Suitable binary backupRestore the backup and mount the database.Perform required recovery, then open with RESETLOGS.
Reliable trace SQLReconcile the script with the database structure and re-create the control file.An intact-redo NORESETLOGS reconstruction can permit normal opening after complete recovery.
No usable copy, backup, or traceReconstruct only from a verified database inventory.This is an expert recovery task whose success cannot be assumed.

For example, if one of two current copies is inaccessible because its volume failed, preserve the surviving copy and investigate replacement. Restoring an older backup unnecessarily introduces a different recovery procedure. If both current copies are lost but an RMAN autobackup is available, evaluate that backup before composing CREATE CONTROLFILE manually.

Path 1: Replace a Damaged Copy from a Current Copy

Stop the instance before copying the surviving current control file. Repair the failed destination or select a supported replacement location, copy using tools appropriate to the storage, and ensure CONTROL_FILES identifies the intended copies before restarting. Do not copy an actively changing control file with a generic operating-system command and treat the result as a valid online backup.

A filesystem copy command is not an ASM file-management procedure. Likewise, changing a configured destination requires the appropriate SPFILE or PFILE handling. CONTROL_FILES is static, so a changed configuration must take effect through the planned restart. Preserve the existing configuration until the replacement plan is clear.

Oracle documents that replacing a failed copy from an intact current copy does not itself require media recovery. Independent datafile damage or an unclean shutdown may still have recovery consequences. See Managing Control Files.

Path 2: Restore a Binary Backup with RMAN

When no current copy survives, a binary backup provides an established starting point. It also retains information that a reconstruction script does not reproduce in full, including backup-related records. Converting a binary backup into trace SQL is not a mandatory intermediate step.

The following RMAN example assumes no recovery catalog, a known DBID, usable initialization configuration, and an accessible disk autobackup that RMAN can locate. Connect to the correct CDB target as an authorized user with SYSBACKUP or SYSDBA. Replace the illustrative DBID with the database's recorded identifier.

SET DBID 1234567890;
STARTUP NOMOUNT;
RESTORE CONTROLFILE FROM AUTOBACKUP;
ALTER DATABASE MOUNT;
RECOVER DATABASE;

Issue STARTUP NOMOUNT only if the instance is down. If it is already in NOMOUNT, continue there. Nondefault autobackup formats, older search windows, and media-manager backups require matching search or channel details. An unqualified autobackup search does not inspect every possible storage location.

Restore normally writes to the configured control-file destinations, which must be accessible. Review recovery output before proceeding. Once recovery succeeds, open with:

ALTER DATABASE OPEN RESETLOGS;

Backup-control-file recovery requires RESETLOGS even when complete recovery succeeds. This requirement alone does not mean committed changes were lost. See Performing RMAN Recovery: Advanced Scenarios.

Do not automatically restore every datafile just because the control file was restored. Usable existing files can be part of the recovery plan. Conversely, damaged files, a changed recovery target, or missing required redo need explicit treatment. The short example assumes those requirements have already been assessed.

The restored repository may predate recent backups or structural changes. If recovery requests an unknown log, investigate its identity and location and reconcile the repository as appropriate. Do not interpret the message as permission to cancel recovery and open at an unexamined boundary. Keep the intended recovery outcome separate from the availability of a particular backup.

Path 3: Re-create the Control File from Trace SQL

Trace-based reconstruction is useful when a reliable script describes the database and the required files remain available. The Oracle 26ai Backup and Recovery User's Guide, section 37.3, documents reconstruction with NORESETLOGS when the online redo remains intact. This path differs from restoring a binary backup.

Capture the Trace Before a Failure

While the database is mounted or open and a control file is usable, generate trace SQL from an appropriately privileged CDB-root session:

ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

The trace contains a CREATE CONTROLFILE statement and related instructions. It may include alternative recovery branches and later tempfile commands. Preserve the original output before editing a working script.

To inspect the current session's default trace destination:

SELECT value
FROM v$diag_info
WHERE name = 'Default Trace File';

Locate and verify the generated output. Trace generation depends on existing control-file information; it cannot reconstruct an unknown structure after every usable copy has disappeared. Refresh and protect the trace following structural changes, alongside binary backups.

Review the Script Against the Actual Database

A script that ran successfully for an older database structure may be wrong today. Compare its date with changes to tablespaces, files, redo members, and PDBs. The alert log can help reconstruct that history, but it is supporting evidence rather than a guaranteed complete inventory.

Review before executing reconstruction SQL
CheckWhy it matters
Identity and character setPreserve the correct database name and generated character-set information.
CDB file inventoryAccount for root, seed, and PDB files and subsequent structural changes.
Redo groups and membersVerify actual locations and availability before selecting the intact-redo path.
Logging and other clausesPreserve intended settings, including FORCE LOGGING where applicable.
Destinations and REUSEConfirm writable destinations and understand which existing files could be overwritten.
Special file statesHandle read-only files, offline files, and tempfiles according to their documented procedures.

Do not replace the inventory with a short example listing only SYSTEM and a user tablespace. A modern CDB contains additional structures. Use the actual generated statement and verified changes. Preserve recoverable files and the incident state before a reconstruction that could affect them.

Execute the Reviewed Reconstruction Procedure

This example assumes reliable trace SQL, intact online redo, unchanged database identity, and a verified NORESETLOGS reconstruction plan. Connect with SQL*Plus as SYSDBA to the CDB root/instance. No instance may have the database mounted when CREATE CONTROLFILE executes.

  1. Establish NOMOUNT. If the instance is down, use STARTUP NOMOUNT. If it is already started, inspect its state and follow the planned transition.
  2. Execute the reviewed statement. Use a script whose contents and recovery branch have been checked.
  3. Confirm creation. Successful CREATE CONTROLFILE mounts the database automatically. Do not issue an unconditional second MOUNT.
  4. Complete recovery. Resolve required redo and any recovery errors before opening.
  5. Open and verify. Follow the opening method appropriate to this reconstruction and recovery.

For the following illustration, the reviewed script contains only the database-specific CREATE CONTROLFILE statement. It does not contain startup, recovery, or opening commands. With the instance already verified to be in NOMOUNT:

@/u02/recovery/create_controlfile_reviewed.sql

The path is illustrative. The file must already contain the verified statement for this database. After successful NORESETLOGS creation, perform recovery in SQL*Plus:

RECOVER DATABASE

After the scoped complete recovery succeeds, open normally:

ALTER DATABASE OPEN;

This sequence follows the intact-redo reconstruction procedure in the supplied guide. If online redo is lost or a different recovery boundary is required, reassess the plan. CREATE CONTROLFILE does not manufacture missing transactions. Do not append this sequence to the RMAN backup-control-file procedure as though both were required.

Oracle requires the database to be unmounted for creation and mounts it on success. Review the CREATE CONTROLFILE reference for the statement's restrictions.

Account for Read-Only, Offline, and Temporary Files

A generic instruction to put every file into the DATAFILE clause is insufficient. The supplied guide describes special treatment of read-only and offline-normal files during reconstruction. Such files may be omitted under the documented procedure and later reconciled from MISSING entries. Accidentally omitting a required read/write file is a different problem.

Before renaming a MISSING entry, establish the file's identity, state, and recovery requirements. Do not assume that a filename substitution makes an unknown or damaged file usable. The next lesson develops the read-only recovery case in more detail.

Tempfiles also require separate handling. Trace output can include ALTER TABLESPACE ... ADD TEMPFILE statements for later execution. Preserve the necessary container context and verify the resulting temporary tablespaces. Tempfiles do not belong in a fabricated permanent-datafile list and are not restored like ordinary backed-up datafiles.

Keep Planned Configuration Changes Separate

Control-file reconstruction should not become a routine response to every configuration change. MAXDATAFILES initially sizes the datafile section; that section can expand within DB_FILES limits. A planned database rename should consider DBNEWID, which Oracle recommends instead of CREATE CONTROLFILE for that purpose. Both points are documented in the SQL reference.

Do not carry old sample limits, redo sizes, or paths into the recovery script simply because they appeared in a previous lesson. During an incident, preserve verified settings and restore service. Evaluate unrelated capacity or naming changes through their own planned procedures.

Verify Recovery and Protect the New Starting Point

A successful script does not prove that applications are ready. Review recovery completion messages and outstanding file requirements. Once the database is appropriately mounted or open, inspect the actual control-file locations and identity; after opening, check PDB state:

SELECT name, status FROM v$controlfile;

SELECT name, dbid, open_mode, log_mode
FROM v$database;

SELECT con_id, name, open_mode FROM v$pdbs;

A blank control-file status is not by itself an error. Correlate the results with the expected locations and diagnostics. Confirm that intended PDBs and services are available, required permanent and temporary files are accounted for, and representative application reads succeed.

Re-creating the control file does not reconstruct every RMAN repository record. Reconcile required backup and incarnation information using a recovery catalog or supported catalog and registration procedures. Earlier backups are not automatically worthless after RESETLOGS, but their usability depends on the required metadata and recovery chain.

Back up the reconstructed control file promptly. In an appropriately connected RMAN session:

BACKUP CURRENT CONTROLFILE;

Restore verified multiplexing on separate failure domains, retain binary backups and current trace SQL, and protect the SPFILE, DBID, configuration, and file inventory. A fresh database backup can provide a convenient recovery starting point. Test access to those resources before the next incident; multiple copies reduce risk but cannot eliminate every shared failure.

The next lesson describes how to recover a read-only tablespace.


SEMrush Software 5 SEMrush Banner 5