【Vegas改编】RMAN Catalog建立、备份及还原实施

Oracle RMAN 备份恢复教程
本文介绍Oracle RMAN工具的基本使用流程,包括创建恢复目录、注册数据库、增量级别备份与恢复、脚本创建及执行等关键步骤,并提供实例说明如何进行完整的数据库备份和恢复操作。

-- Target DB ORACLE_SID=oralin CATALOG DB ORACLE_SID=oratest

******************************************************************

1. Create catalog DB and register database.
    1.1. Connect to the catalog database and Create tablespace for the catalog:

  SQL> create tablespace RMAN_ORALIN datafile '/u01/app/oracle/oradata/oratest/RMAN_ORALIN.dbf' size 50M;

           
    1.2. Create Recovery Manager User:   

SQL> CREATE USER rmanoralin  PROFILE DEFAULT IDENTIFIED BY rmanoralin DEFAULT TABLESPACE RMAN_ORALIN TEMPORARY TABLESPACE TEMP quota unlimited on RMAN_ORALIN;

            
    1.3. Grant the role and privilege to  this user to maintain the recovery catalog and perform the backup and recovery operations.
    

 

SQL> GRANT RECOVERY_CATALOG_OWNER TO rmanoralin;
SQL
> GRANT CONNECT,RESOURCE TO rmanoralin;

         
    1.4. Create catalog.

$ rman catalog rmanoralin/rmanoralin msglog=rmanoralin.log     
RMAN
> create catalog tablespace RMAN_ORALIN;
RMAN
> exit;

       
    1.5. Check rmanoralin.log 
   
    1.6. Log in as a user with SYSDBA priviledge on the target database tp perform all the backup and recovery operations.

$ rman target / catalog rmanoralin/rmanoralin@oratest

  Recovery Manager: Release 10.1.0.2.0 - Production

 Copyright (c) 1995, 2004, Oracle.  All rights reserved.

 connected to target database: ORALIN (DBID=34306947)
 connected to recovery catalog database
  
    
1.7. Register target database in the catalog. 

 

RMAN> register database;

 database registered in recovery catalog
 starting full resync of recovery catalog
 full resync complete


*******************************************************
2. Backup databse using RMAN catalog and incremetallevel 0;

run {
         allocate channel d1 type 
disk;
         
backup incremental level=0  filesperset 3 format '/u01/app/oracle/oradata/oralin/backup/%d.s%s.t%t.L0'
         ( 
database include current controlfile);
          sql 
'alter system archive log current';
          sql 
'alter system archive log current';
          sql 
'alter system archive log current';
          
backup filesperset 3 format '/u01/app/oracle/oradata/oralin/backup/ARCH.%d.s%s.t%t'
          (archivelog 
all delete input);
         }

       *******************************************************************************************

3. Backup database using RMAN catalog and incremetallevel 1;

    resync catalog;
    run {
         allocate channel d1 type 
disk;
         
backup incremental level=1  filesperset 3 format '/u01/app/oracle/oradata/oralin/backup/%d.s%s.t%t.L1'
         ( 
database include current controlfile);
          sql 
'alter system archive log current';
          sql 
'alter system archive log current';
          sql 
'alter system archive log current';
          
backup filesperset 3 format '/u01/app/oracle/oradata/oralin/backup/ARCH.%d.s%s.t%t'
          (archivelog 
all delete input);
         }

        
    *******************************************************************************************
    
4. Create script and stroe in catalog db , and use store scripts to backup.
    4.1. Create script example:       

RMAN > create script level0backup {
                 allocate channel d1 type 
disk;
           
backup incremental level=0  filesperset 3 format '/u01/app/oracle/oradata/oralin/backup/%d.s%s.t%t.L0'
           ( 
database include current controlfile);
           sql 
'alter system archive log current';
           sql 
'alter system archive log current';
           sql 
'alter system archive log current';
           
backup filesperset 3 format '/u01/app/oracle/oradata/oralin/backup/ARCH.%d.s%s.t%t'
           (archivelog 
all delete input);
                }      

       

   
    4.2. Execute script example:        

RMAN> run { execute script level0backup;};    

  
         
    *******************************************************************************************

 

5. Restore all datafile  include control file and imcomplete recovery database.
   5.1  Connect target and catalog DB.       

$ rman target / catalog rmanoralin/rmanoralin@oratest

        
   5.2   Startup nomount target DB.     

RMAN> startup nomount;

        
   5.3  restore target DB's control files.       

RMAN> restore controlfile;

                       
   5.4   Startup mount Target DB

RMAN>  sql 'alter database mount';

        
   5.5.   Restore target data files and auto-recovery database.

RMAN> restore database;
RMAN
> recover database;               
RMAN
> exit

              
   5.6   Incomplete recovery and open database  resset logs.

$ sqlplus / as sysdba
SQL
> recover database using backup controlfile until cancel;
SQL
> alter database open resetlogs;  

                

   5.7. If using a recovery catalog , register the new incarnation of the database:

RMAN> reset database;

 

 

   *******************************************************************************************       
       
6. Restore a database to a previous incarnation.
   6.1 List the incarnation of database:

RMAN> list incarnation of database;

       
   6.2 Start the instance in the NOMOUNT state:

RMAN> startup nomount;

       
   6.3 Reset the database to the previous incarnation.

RMAN> reset database to incarnation 2;

        
   6.4 Restore the control file from the previous incarnation.    

RMAN> restore controlfile;

                    
   6.5 Mount the database.   

 

RMAN> sql 'alter database mount';

  
   6.6 Restore the database. 

RMAN> restore database;

               
   6.7 Recover the database. 

RMAN>recover database;
RMAN
>exit;

              
   6.8   Incomplete recovery and open database  resset logs.      

$ sqlplus / as sysdba
SQL
> recover database using backup controlfile until cancel;
SQL
> alter database open resetlogs;    

              

   6.9 If using a recovery catalog , register the new incarnation of the database: 

RMAN> reset database;

 

 

 

 

转载于:https://www.cnblogs.com/amadeuslee/archive/2009/09/01/3744294.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值