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

2年前 (2022) 程序员胖胖胖虎阿
291 0 0

-- 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;

 

 

 

 

相关文章

暂无评论

暂无评论...