Catalog Maintenance   «Prev  Next»

Lesson 8 Using the delete and validate command
Objective Use delete command to remove data from your recovery catalog

Using the Delete and Validate Command to remove data from Recovery Catalog

Use the delete command to remove data from your recovery catalog and the validate command to check the validity of your recovery catalog.
There may be instances when you need to re-create your database. You may need to re-create some data files, move them to other locations, or rename them. After you do this, the information in the recovery catalog may contain invalid data. You can remove this information through the use of the delete command. The delete command is used to remove any old or unused file references from the control file and/or recovery catalog. The delete command is different from any of the other change command options in that it will tell the underlying operating system to delete files physically. When RMAN has to talk to the operating system, you have to allocate a channel. Allocating a channel will beis discussed later in this course. The following example uses the allocate command.

Example
In this example, we will perform the following steps:
  1. Allocate a channel to talk to a disk
  2. Perform the change delete command.
  3. Release the channel.

An example is when you have changed your backup strategy and relocated where backup data file copies reside. The old backup files may still be known to the recovery catalog. The code below demonstrates how to get rid of this information.
RMAN>allocate channel for delete type = 'disk';
RMAN>change datafilecopy 'd:\backup\userorc1.bak' delete;
RMAN>release channel;

How to remove outdated or relocated backup information from the Oracle Recovery Catalog

The example above correctly demonstrates how to remove outdated or relocated backup information from the Oracle Recovery Catalog using RMAN.
Here's a breakdown of the process:
Code Explanation:
  • RMAN> allocate channel for delete type = 'disk';
    
    • Purpose: This line allocates an RMAN channel of type 'disk' for the delete operation. RMAN uses channels to perform backup, restore, and delete operations. Since the backup files in question reside on disk, a disk channel is specified.
  • RMAN> change datafilecopy 'd:\backup\userorc1.bak' delete;
    

    • Purpose: This command tells RMAN to remove the reference to the specified data file copy (`d:\backup\userorc1.bak`) from the recovery catalog and the control file. It does not delete the physical file from disk; it only removes RMAN's knowledge of it.
    • The `CHANGE` command is often used to update RMAN's metadata about backups, including marking backups as unavailable or deleting them from the RMAN catalog when they are no longer needed or have been manually moved/deleted.
  • RMAN> release channel;
    

    • Purpose: This command releases the channel that was allocated for the operation. It's important to release the channel after performing RMAN operations to free up resources.

Scenario Context:
  • Changing Backup Strategy: When you change your backup strategy and relocate backup files (e.g., moving them to a new location or replacing old backups with new ones), the old file references may remain in the RMAN catalog, even if the files no longer exist on disk.
  • Purpose of the Script: This script ensures that the RMAN catalog (and optionally the control file) is updated, removing references to old or relocated data file copies that are no longer valid.

Key Notes:
  • This approach is appropriate when you've relocated backups and no longer need RMAN to track the old backup files.
  • You can also use `CROSSCHECK` followed by `DELETE EXPIRED` to clean up the RMAN catalog if you are unsure which files still exist.

In summary, the code correctly demonstrates how to remove obsolete information about data file copies from the recovery catalog and control file in Oracle.

Change...validate

  1. When you have gone through the process of deleting several files, you may be unsure whether the recovery catalog properly reflects what is left.
  2. The validate command will reconcile what is left on disk with what is in the recovery catalog.
  3. If a file is found to not exist, the reference to the file is removed from the recovery catalog and the control file.
  4. The validate command can also be used to validate a control file if a recovery catalog is not present.

Let us analyze these 4 statements in the context of Oracle 23c and how the "Oracle Recovery Catalog" functions:
  1. When you have gone through the process of deleting several files, you may be unsure whether the recovery catalog properly reflects what is left.
    True: After deleting files (i.e., archived logs, backup pieces), it's possible that the recovery catalog still holds references to these deleted files. You may indeed be unsure whether the recovery catalog is up to date, especially if manual file deletions were made outside of RMAN.
  2. The validate command will reconcile what is left on disk with what is in the recovery catalog."
    False: The `VALIDATE` command in RMAN is used to check the integrity of backups (whether they can be restored) and files (e.g., datafiles, control files, or archivelogs). However, it does not reconcile what is left on disk with the recovery catalog. To synchronize the recovery catalog with what is actually present on disk, the CROSSCHECK command is used. `CROSSCHECK` updates the status of backups and archived logs in the recovery catalog or control file by verifying their existence on disk or tape.
  3. If a file is found to not exist, the reference to the file is removed from the recovery catalog and the control file.
    False: If a file is found to not exist during a `CROSSCHECK`, its status in the recovery catalog (or control file) is marked as EXPIRED, but the reference to the file is not immediately removed. It simply means that RMAN recognizes the file is no longer available. To permanently remove the references, you would need to use the `DELETE EXPIRED` command to delete these expired records from the recovery catalog or control file.
  4. "The validate command can also be used to validate a control file if a recovery catalog is not present."
    True: You can use the `VALIDATE` command to check the integrity of the control file, even if a recovery catalog is not in use. RMAN can work with the control file only mode when no recovery catalog is available, and `VALIDATE` can be used in this context to ensure the control file is usable.

Example

You have been working with your client's archivelog files and are not sure whether you have deleted all references in the recovery catalog.
The following command will reconcile the recovery catalog with the actual files that exist on the disk:
RMAN>change archivelog all validate;

The next lesson is the module conclusion.

SEMrush Software