rman 维护 - ( crosscheck + retention + keep + catalog)

来源:互联网 发布:360软件应用 编辑:程序博客网 时间:2024/05/16 10:57
  

This time ,I will introduce the Rman maintenance:
After completing this lession, you should be able to do the following:

  1: Perform Cross-checking of backups and copies.
  2: Update the repository when backups have been deleted.
  3: Change the available status of backups and copies
  4: Make a backup or copy exempt from the retentinon policy
  5: Catalog backups made with operating system commands.
 

Step1:
  First take a look at the "retention Policy":
  1:  Recovery window of 7 days
  2:  Redundancy 2;
  3:  None
 
  Reason of the "setting of retention policy":
  When the Database up from day to day, the rman backup file will become bigger and begger,
  Although the DBA can delete or achive the database mannually, but the Oracle rman function
  can help the database archive the rman backup files automaticlly if you use above rman setting.
 
  setting instruction:
  1: recovery window of days:
    if today the database crushed, the database can recovery using the backup files 7 days ago.
    example:
    if you define the database backup on Jan 1, Jan 14, Jan 28 based on the every 2 weeks,
    Unfortunately, when in the day of "Jan 23", the database crushed, we know the backup is as below:
    Jan 1  - (no need)
    Jan 14 - (need)
    Jan 23 - (Today)
    Jan 28 - (will backup database as schedule)
   
    The database recovery step:
    if you had setting the "Configure retention policy to recovery window of 7 days",
    Jan 16 - (today -7) the database will restore this day at least.
   
    The database recovery from Jan 14 level 0 backup and plus 2 days archive datalog.
    the backup file of "Jan 1 is no needed".
   
    2: Redandancy 2;
    This setting for the bopies of backups. if you set the rman in this way, datbase will remain
    the backup copies only for 2 copies. the orignal copies will expire.
   
    3: None,
    The database will remain all the backup copies.
   
    Sometime, you can use "report obsolete" to check which backup file is obsolete, then you
    can execute "delete obsolete" to delete the obsoleted files.

Step2:
    Following I will give some concept of "crosscheck".
    if you use the command of "crosscheck backupset", this command is to ask the database
    check the backupset files in the phsical location and the record in rman resgister.
   
    example:
    1: If you delete the backupfile mannually, but the rman still not know the file and not
    been available,
    2: so if you execute command " list backup " you will see the backup file status is "available"
    3: But if you execute command "crosscheck backupset" befor step2, rman will check the backupfile if
    available or not, then the rman will give you a response: "expired".
   
    Command of related:
   
    crosscheck backupset
    crosscheck backup of database
    crosscheck copy
    crosscheck backup tablespace users;
    crosscheck backupset 1001,1002;
    crosscheck backuppiece tag = 'weekly_backup';
    crosscheck controlfile '/tmp/control.ctl';
   
    If the backup file is not available, you can use below command to delete the record in rman:
    delete expired  backupset
   
    At last, I will clarify the concept of "obsolete and expired":
      The term obsolete does not mean the same as expired. A backup is obsolete when "REPORT OBSOLETE"
      or "DELETE OBSOLETE" determines, based on the user-defined retention policy, that it is not needed
      for recovery. A backup is considered expired only when RMAN perform a crosscheck and can not find
      the file. In short, obsolete means "not needed" where as expired means "not found".

     
Step3:
    I will compare the command "delete obsolete" with "rm backupfile" for physical deleting:
    delete obsolete command will also delete the physical file , as well as deleting the record in rman.
   
    so we suggest use " delete obsolete" in rman to delete the file.
   
    if you do not want the rman give you a confirmation message, you can use "noprompt":
   
      Delete noprompt expired backup of tablespace users;
  
    Use of delete in Rman:
      delete archived redo log files:
      BACKUP ARCHIVELOG ALL DELETE INPUT;
      BACKUP ARCHIVELOG SEQUENCE BETWEEN 99 AND 199 THREAD 1 DELETE INPUT;
     
     ---------------
     If you do not delete the backupfile in rman, you can use below command:
      Change backupset 101 (back_number) unavailable
     Since the action, the backupfile will not active if you want to restore the database,
    
     If you want to restore the database using this backupfile, you can:
       Change backupset 101 (back_number) available
      
Step4:
     If you want one rman bakup file keep exempt of retention policy, you can use command:
       Change ... keep
      
     example:
       change backupset 123 keep forever nologs;
       change datafilecopy '/u02/backup/user.dbf' keep until 'sysdate+60';
    
     if you want to release the keep, you can use:
       change backupset tag year_end_2010 nokeep
      
Step5:
      Catalog command:
      use this command to add file to rman record:
     
      example:
      catalog datafilecopy '/u02/backup/user01.dbf';
      catalog archivelog '/u01/archive/arch_12.arc';
      catalog start with'/u01/app/backup' noprompt;
     
      If you have to catalog multiple files that had backuped up to a directory, use the catalog
      start with command.
     
        When you issue the catalog recovery area command, RMAN rearches for all files in the
      recovery area and issues a message if it doesn't find any files known to the database.
        RMAN> catalog recovery area
       
      change uncatalog:
        Remove records from rman
       
        example:
        Change archivelog ... uncatalog;
        change datafilecopy '/u01/backup/user01.dbf' uncatalog;
        change backupset backup_no uncatalog
        change backuppiece backup_piece_no uncatalog