Search

Join this Blog for direct reference of any post into your inbox. To join just click on "Join this Site" under "Follower" then Login with your Email.*** DECLARATION: I Maintain this Blog for Helping Myself While at Work and Welcome any body Needing Help!!!.*** CAUTION: Using any of the script from this Blog may contain at Own Risk. These scripts May or May not have been Tested.***

Saturday, 7 July 2012

RMAN Important Commands Description.

ALLOCATE CHANNEL
This command is used to manually allocate a channel, which is a connection between RMAN and a database instance. Each connection initiates an Oracle server session on the target or auxiliary instance. This server session performs the work of backing up, restoring, or recovering backup sets and copies. 
allocate channel d1 type disk FORMAT "D:\RMAN_BACKUP\Weekly_Orcl3_Full%s.db";
allocate channel d2 type disk FORMAT "D:\RMAN_BACKUP\Weekly_Orcl3_Full%s.db";
The above example is used to take rman full incremental level 0 backup with the archivelog backup (deleting the archivelog input after backup) with two separate channel d1, d2. The multi channel concept will decrease the total time to accomplished backup.
Restriction:
You cannot specify BACKUP DEVICE TYPE or RESTORE DEVICE TYPE after running ALLOCATE CHANNEL.
You cannot prefix ORA_ to a channel name as RMAN reserves channel names beginning with the ORA_ prefix for its own use.
You can Execute ALLOCATE only within the braces {} of a RUN.
You must use a recovery catalog when backing up a standby database.
You cannot make a connection to a shared server session.
ALLOCATE CHANNEL FOR MAINTENANCE
This command is used to manually allocate a channel in preparation for issuing a CHANGE, DELETE or CROSSCHECK command. If you use CONFIGURE to set up automatic channels, then RMAN can use these automatic channels for maintenance operations; you do not need to have to manually allocate them.
Example: Deleting a Backup piece
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE disk;
DELETE BACKUPPIECE 'D:\backup\rman_backup\hotbackup\daily_arc_1398';
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
DELETE BACKUPSET 101,102,103,501,502,506;
The first example deletes the backup piece from the disk only where as the second delete the 6 backupset from both disk and tape.
Example: Crosschecking a Backupset:
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
CROSSCHECK BACKUPSET 10708;
RUN
{
  SET AUTOLOCATE ON;
  ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK CONNECT 'SYS/oracle@orcl3';
  ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK CONNECT 'SYS/oracle@orcl4';
  CROSSCHECK BACKUP;
}
The above two example is used to crosscheck backup on disk. The first example crosschecks the backupset with primary key 10708 where as the second example crosschecking backup on two node of RAC environment.
CATALOG
This command is used to add metadata about a user managed datafile, controlfile or archived log copy to the recovery catalog and control file and Record a datafile copy as a level 0 backup in the RMAN repository, which enables you to use it as part of an incremental backup strategy.
CATALOG ARCHIVELOG 'D:\Backup\oradata\archive1_30.dbf','D:\Backup\oradata\archive1_31.dbf',' D:\Backup\oradata\archive1_32.dbf';
In the above example that you made operating system copies of archived logs or transferred them from another location, and then added them to the RMAN repository.
CATALOG DATAFILECOPY 'D:\rman_Backup\main_dbf.db' LEVEL 0;
The above example catalogs datafile copy main_dbf.db as an incremental level 0 backup.
Note: Note that you can create datafile copies both with the RMAN COPY command and by using with ALTERTABLESPACE BEGIN/END BACKUP.
CHANGE
The CHANGE command is used to make the following changes:
  • Change the status of backups, copies, and archived logs in the repository to AVAILABLE or UNAVAILABLE. This is useful when a previously unavailable file is made available again, or you do not want a specific backup or copy to be eligible to be restored but also do not want to delete it.
  CHANGE BACKUPSET 100 UNAVAILABLE; 
  • Remove catalog records for backups and copies, and update the corresponding records in the target control file to status DELETED. This is useful when you remove a file by using an operating system command rather than the RMAN CHANGE command, and want to remove its repository record as well.
   RMAN> CHANGE DATAFILECOPY 'D:\rman_backup\maindbf.db' UNCATALOG;
  • Specify that a backup or copy should either abide by the currently configured retention policy or be exempt from it.
      CHANGE BACKUPSET 10472 KEEP FOREVER NOLOGS;
Restrictions:
·      Use CHANGE only on files that are recorded in the RMAN repository and belong to the current database incarnation.  
·      The KEEP FOREVER clause requires use of a recovery catalog.  
·      When using the CHANGE command to delete a backup, first allocate a channel so that the operating system can delete the file associated with that backup.
Note: To obtain the primary keys of the records whose status you want to change, run a LIST command or query the recovery catalog views.
CONFIGURE
The CONFIGURE command is used to configure persistent settings affecting RMAN backup, restore, duplication, and maintenance jobs. These configurations are in effect for any RMAN session until the configuration is cleared or changed.
Note: RMAN uses default settings for CONFIGURE options. You can return to the default value for any CONFIGURE command by running the same command with the CLEAR option.
Configuring Backup Optimization:
By configuring Backup optimization RMAN, BACKUP command does not back up files to a device type if the identical file has already been backed up to the device type. So overall backup time of database is reduced when RMAN skip the file that is already backed up.
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE BACKUP OPTIMIZATION CLEAR;
Configuring a Retention Policy:
This example configures a retention policy with a recovery window of 14 days, and then resetting the default retention policy to REDUNDANCY = 1
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
CONFIGURE RETENTION POLICY CLEAR;
Configuring Automatic Disk and Tape Channels:
This example configures generic DISK and sbt channels, sets the default device type to sbt, and sets PARALLELISM to 3:
CONFIGURE CHANNEL DEVICE TYPE DISK RATE 5M;
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS 'ENV=(NSR_SERVER=bksrv1)';
Configuring Automatic Channels Across File Systems:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT 'D:\backup\%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'E:\backup\backup/%U';
Configuring Automatic Channels in an Oracle Real Application Clusters Configuration:
CONFIGURE CHANNEL 1 DEVICE TYPE sbt CONNECT 'SYS/oracle@orcl3'
PARMS 'ENV=(NSR_SERVER=bkserv1)';
CONFIGURE CHANNEL 2 DEVICE TYPE sbt CONNECT 'SYS/oracle@orcl4'
PARMS 'ENV=(NSR_SERVER=bkserv2)';
Clearing Automatic Channels:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK CLEAR;
CONFIGURE CHANNEL DEVICE TYPE sbt CLEAR;
Configuring and Clearing Parallelism:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE DEVICE TYPE DISK CLEAR;
Configuring Backup Copies:
This example configures duplexing to 3 for DISK backups of datafiles and control files and then runs a database backup:
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 3;
BACKUP DATABASE FORMAT 'D:\backup\%U', 'E:\backup\%U', 'F:\backup\%U';
Configuring the Snapshot Control File Location:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\backup\sncforcl2.ora';
CONFIGURE SNAPSHOT CONTROLFILE NAME CLEAR;
Excluding a Tablespace from a Whole Database Backup:
This example excludes the read-only reports tablespace from whole database backups, and then returns the reports tablespace to the default behavior of "not excluded":
CONFIGURE EXCLUDE FOR TABLESPACE reports;
CONFIGURE EXCLUDE FOR TABLESPACE reports CLEAR;
Specifying the Default Format for the Control File Autobackup:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\backup\%F';
CONFIGURE CONTROLFILE AUTOBACKUP CLEAR;
COPY
This command is used to create an image copy of a file. In many cases copying datafiles is more beneficial than backing, you can perform media recovery directly on datafile copy but not on backupset.
Note: If AUTOBACKUP is set to ON then RMAN automatically perform a controlfile auto backup after each and every backup or copy command issued.
This example copies the datafile tbs_01.f with the NOCHECKSUM option to the output file temp3.f, marking it as a level 0 backup:
COPY
  NOCHECKSUM
  DATAFILE 'D:\oracle1\oradata\orcl3\rtbs.dbf' TO 'D:\Backup_copy/rtbs_copy' LEVEL 0;
This example copies the current control file and gives the copy the tag weekly_cf_copy:
COPY
  CURRENT CONTROLFILE TO 'd:\backup_copy\control01.db'
  TAG = weekly_cf_copy;
This example copies the database and exempts it from the current retention policy:
COPY
  KEEP FOREVER NOLOGS
  CURRENT CONTROLFILE TO 'd:\backup_copy/control01.db',
  DATAFILE 1 TO 'd:\backup_copy\df1.copy';
CREATE SCRIPT
The CREATE SCRIPT command is used to create a script and store it in the recovery catalog for future reference. Stored scripts provide a common repository for frequently executed collections of RMAN commands. Any command that is legal within a RUN command is permitted in the stored script. The script is not executed immediately; run the script with @.
This example creates a script called b_whole_10 that backs up the database and archived redo logs, then executes it:
CREATE script weekly_backup
{
 ALLOCATE CHANNEL d1 DEVICE TYPE disk;
 BACKUP INCREMENTAL LEVEL 0 TAG weekly_backup DATABASE PLUS ARCHIVELOG;
}
RUN { EXECUTE script weekly_backup;}
Note: Rman must be connected to the recovery catalog. A connection to target database is not required. Execute the script only at rman prompt. You can simple delete script with delete script command.
CROSSCHECK
The CROSSCHECK command is used to verify the existence of backups and copies stored on disk or tape. It checks and marked AVAILABLE or EXPIRED, either by examining the files on disk for DISK channels or on the tape for sbt channel by matching or tally with the catalog repository.
RMAN does not delete any files that it is unable to find, but updates their repository records to EXPIRED. You can determine which files are marked EXPIRED by issuing a LIST EXPIRED command. Then, you can run DELETE EXPIRED to remove the repository records for all expired files.
CROSSCHECK BACKUP;
CROSSCHECK BACKUP DEVICE TYPE disk COMPLETED BETWEEN '01-JAN-01' AND '01-JUL-12';
RESYNC CATALOG

It will perform a full resynchronization of metadata in a recovery catalog schema with metadata in a target database control file. You can also use the FROM CONTROLFILECOPY clause to resynchronize the current control file with the RMAN metadata in a control file copy. The Resynchronizations are of full or partial.
In case of Full, RMAN updates all changed records for the physical schema: datafiles, tablespaces, redo threads, and online redo logs (if DB mounted). If the DB is open then it will also obtain data about rollback segments.
If the resynchronization is partial, then RMAN does not resynchronize metadata about the physical schema or rollback segments.
Typically, you run RESYNC CATALOG in the following situations:
§         The recovery catalog was unavailable when you executed RMAN commands that automatically perform a resynchronization.
§         The target database is running in ARCHIVELOG mode, because the recovery catalog is not updated automatically when an online redo log switch occurs or when a redo log is archived.
§         You made changes to the physical structure of the target database such as adding or dropping a tablespace or datafiles. As with log archiving, the recovery catalog is not updated automatically when the physical schema changes.
§         RMAN is connected as TARGET to a standby database. You want to update the recovery catalog with metadata about RMAN operations performed on this database.
§         RMAN is connected as TARGET to a standby database. You want to update the recovery catalog with metadata about a physical change on the primary database.
Caution: RMAN must be connected as TARGET to a mounted or open database and connected as CATALOG to a recovery catalog database.
If the target control file is mounted and the catalog database is available at command execution, then RMAN automatically resynchronizes the recovery catalog as needed when you use RMAN commands.
RMAN performs a full resynchronization after structural changes to database (adding or dropping database files, creating new incarnation, and so on) or after changes to the RMAN persistent configuration.

DROP CATALOG
This command is used to remove the schema from the recovery catalog.
Caution: This command deletes all metadata from the recovery catalog. If you have no backups of the catalog, then all backups of all databases managed by this recovery catalog become unusable.
This example drops the schema from the recovery catalog.
RMAN> DROP CATALOG
recovery catalog owner is rman
enter DROP CATALOG command again to confirm catalog removal
RMAN> DROP CATALOG
HOST
This command is used to invoke an operating system command-line sub-shell from within RMAN.
The below example shuts down the database, makes a backup of datafile main_dbf, then making an image copy of the same file on disk by using a UNIX command.
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
BACKUP DATAFILE '$ORACLE_HOME/dbs/main_dbf.db';
HOST 'cp $ORACLE_HOME/dbs/main_dbf.db $ORACLE_HOME/dbs/copy/main_dbf.db';
ALTER DATABASE OPEN;
The below example makes an image copy of datafile main_dbf, using hosts out to the UNIX prompt to check that the copy is in the directory then resumes the RMAN session again:
COPY DATAFILE 3 TO 'main_dbf.db';
HOST;
  % ls main_dbf.db
  Main_dbf.db
  % exit
LIST COPY;
log_archive_duplex_dest
The log_archive_duplex_dest parameter allows you to define not one but two archived redo log storage locations. You can define it or must succeed operation by setting the log_archive_min_succeed_dest parameter. This second parameter, if set to 1, does not require that the archived redo log copy to the duplex destination be complete; otherwise, if the parameter is set to a 2, both copies must be successful. If the parameter is set to 2, the database halts until the reason that the archive log cannot be copied is corrected.
RMAN - Data Dictionary Views
select * from V$BACKUP_DATAFILE; Information from the control file about backup datafiles and control files.
select * from V$BACKUP_DEVICE; Information about various devices available from various third-party manufacturers.
select * from V$BACKUP_CORRUPTION; Information about corrupted blocks discovered during database backups with RMAN
select * from V$BACKUP_piece; Information about all backup sets from the control file.
select * from V$BACKUP_REDOLOG; Information about backed up redo logs in backup sets.
select * from V$DATAFILE_HEADER; Information about database datafile headers.
The below 3 views is used for recovery catalog database
rc_copy_corruption: Contains reports of corruption detected during backups using the recovery catalog.
rc_stored_script: Contains the database names and script names for scripts that are stored in RMAN.
rc_stored_script_line: Contains the text of scripts stored in the recovery catalog.

1 comments:

  1. Bluehost is one of the best web-hosting company with plans for all of your hosting needs.

    ReplyDelete