Oracle's Recovery Manager (RMAN) is a powerful command-line utility used for backing up, restoring, and recovering Oracle databases. Here's a breakdown of common RMAN commands, categorized by their primary function:
Essential RMAN Commands
These commands are fundamental for interacting with RMAN and performing basic operations.
* CONNECT: Establishes a connection to a target database, auxiliary database, or recovery catalog.
* Example: CONNECT TARGET / (connects to the target database as SYSDBA)
* Example: CONNECT CATALOG rman/password@catdb (connects to a recovery catalog)
* RUN: Executes a block of RMAN commands. Many operations, especially those involving channel allocation, are enclosed within a RUN block.
* Example:
RUN {
BACKUP DATABASE;
}
* ALLOCATE CHANNEL: Defines a connection between RMAN and the database instance for I/O operations (e.g., disk, tape).
* Example: ALLOCATE CHANNEL d1 DEVICE TYPE DISK;
* RELEASE CHANNEL: Deallocates a previously allocated channel.
* CONFIGURE: Configures persistent RMAN settings, which remain in effect across RMAN sessions.
* Example: CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
* Example: CONFIGURE DEFAULT DEVICE TYPE TO DISK;
* Example: CONFIGURE CONTROLFILE AUTOBACKUP ON;
* SHOW: Displays current RMAN configuration settings.
* Example: SHOW ALL;
* Example: SHOW RETENTION POLICY;
* REPORT: Provides various reports about the database, backups, and recovery needs.
* Example: REPORT SCHEMA; (shows the database schema)
* Example: REPORT OBSOLETE; (lists backups no longer needed based on retention policy)
* Example: REPORT NEED BACKUP; (lists datafiles that require backup)
Backup Commands
These commands are used to create backups of your database.
* BACKUP DATABASE: Backs up the entire database.
* Example: BACKUP DATABASE;
* Example with archived redo logs: BACKUP DATABASE PLUS ARCHIVELOG;
* BACKUP TABLESPACE: Backs up specific tablespaces.
* Example: BACKUP TABLESPACE users, hr;
* BACKUP DATAFILE: Backs up individual datafiles.
* Example: BACKUP DATAFILE 1, 2;
* BACKUP ARCHIVELOG ALL: Backs up all archived redo logs.
* BACKUP CURRENT CONTROLFILE: Backs up the current control file.
* BACKUP SPFILE: Backs up the server parameter file.
* BACKUP AS COPY: Creates image copies (exact duplicates) of datafiles or the control file, rather than backup sets.
* Example: BACKUP AS COPY DATABASE;
* BACKUP VALIDATE: Checks the validity of backups without actually performing the backup operation. Useful for testing.
* Example: BACKUP VALIDATE DATABASE;
Recovery Commands
These commands are crucial for restoring and recovering your database from backups.
* RESTORE DATABASE: Restores the entire database from backup.
* Example: RESTORE DATABASE;
* RESTORE TABLESPACE: Restores specific tablespaces.
* Example: RESTORE TABLESPACE users;
* RESTORE DATAFILE: Restores individual datafiles.
* Example: RESTORE DATAFILE 3;
* RESTORE CONTROLFILE: Restores the control file.
* Example: RESTORE CONTROLFILE FROM AUTOBACKUP; (restores from an autobackup)
* RECOVER DATABASE: Applies archived redo logs and/or incremental backups to roll forward the database to a consistent state.
* Example: RECOVER DATABASE;
* RECOVER TABLESPACE: Recovers specific tablespaces.
* RECOVER DATAFILE: Recovers individual datafiles.
* BLOCKRECOVER: Recovers individual corrupt data blocks.
Duplication Commands
RMAN's DUPLICATE command is used to create a copy of a target database, often for testing, standby creation, or development environments.
* DUPLICATE TARGET DATABASE TO new_db_name: Creates a duplicate database.
* Example from active database: DUPLICATE TARGET DATABASE TO clone_db FROM ACTIVE DATABASE NOFILENAMECHECK;
* Example using backups:
RUN {
SET UNTIL TIME 'SYSDATE - 1/24'; # To duplicate to a point in time
DUPLICATE TARGET DATABASE TO test_db;
}
Maintenance and Catalog Commands
These commands help manage RMAN's repository and maintain backups.
* CROSSCHECK: Verifies the physical existence of RMAN backups and copies on disk or tape, and updates their status in the RMAN repository.
* Example: CROSSCHECK BACKUP;
* Example: CROSSCHECK ARCHIVELOG ALL;
* DELETE: Deletes backups, copies, and archived logs, and removes their records from the RMAN repository.
* Example: DELETE EXPIRED BACKUP; (deletes expired backups based on crosscheck)
* Example: DELETE OBSOLETE; (deletes backups that are no longer needed based on the retention policy)
* Example: DELETE NOPROMPT BACKUP OF DATABASE; (deletes all database backups without prompting)
* CHANGE: Modifies the status or attributes of RMAN backups and copies.
* Example: CHANGE BACKUPSET 123 UNAVAILABLE;
* Example: CHANGE DATAFILECOPY '/path/to/datafile.dbf' AVAILABLE;
* CATALOG: Adds information about user-managed backups or file copies to the RMAN repository.
* Example: CATALOG START WITH '/u01/app/oracle/oradata/MYDB/datafile/';
* REGISTER DATABASE: Registers a target database with a recovery catalog.
* UNREGISTER DATABASE: Unregisters a target database from a recovery catalog.
* CREATE CATALOG: Creates the schema for the recovery catalog.
* DROP CATALOG: Removes the schema from the recovery catalog.
* RESYNC CATALOG: Synchronizes the recovery catalog with the current control file of the target database.
* UPGRADE CATALOG: Upgrades the recovery catalog schema to a newer version.
* LIST: Displays information about backups, copies, and database schema.
* Example: LIST BACKUP SUMMARY;
* Example: LIST DATAFILE COPY;
This list covers many of the commonly used RMAN commands. For a complete and detailed reference, always consult the official Oracle documentation for your specific database version.
No comments:
Post a Comment