创建rman的catalog 库及备份


1.建好catalog库并建catalog表空间
SQL> create tablespace RCVCAT datafile '/mytestoradata/rcvcat.dbf' size 100M;
Tablespace created.
2.建好管理catalog的rman的user,并给recovery_catalog_owner权限:
SQL> create user RMAN identified by RMAN
2 temporary tablespace TEMP
3 default tablespace RCVCAT
4 quota unlimited on RCVCAT;
User created.
SQL> grant recovery_catalog_owner to RMAN;
Grant succeeded.

3.创建catalog:
standby-> rman
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 16 15:20:36 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> CONNECT CATALOGrman/rman@mytest
connected to recovery catalog database
RMAN> CREATE CATALOG;
recovery catalog created

4.加tnsnames
rac1-> crs_stat -t
Name           Type           Target    State     Host       
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac1       
ora....C1.lsnr application    ONLINE    ONLINE    rac1       
ora.rac1.gsd   application    ONLINE    ONLINE    rac1       
ora.rac1.ons   application    ONLINE    ONLINE    rac1       
ora.rac1.vip   application    ONLINE    ONLINE    rac1       
ora....SM2.asm application    ONLINE    ONLINE    rac2       
ora....C2.lsnr application    ONLINE    ONLINE    rac2       
ora.rac2.gsd   application    ONLINE    ONLINE    rac2       
ora.rac2.ons   application    ONLINE    ONLINE    rac2       
ora.rac2.vip   application    ONLINE    ONLINE    rac2       
ora.racdb.db   application    ONLINE    ONLINE    rac2       
ora....b1.inst application    ONLINE    ONLINE    rac1       
ora....b2.inst application    ONLINE    ONLINE    rac2      
加入catalog的tns到rac 两个实例(rac1,rac2)的tnsnames.ora中:
rac1-> vi tnsnames.ora
mytest =
(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.218.188)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = mytest)
    )
)
5.在rac 库上register database 注册到catalog库
rac1-> rman target / catalogrman/rman@mytest
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Nov 18 09:09:59 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: RACDB (DBID=667104169)
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> REPORT SCHEMA;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    400      SYSTEM               YES     +RACDATA/racdb/datafile/system.259.669487425
2    200      UNDOTBS1             YES     +RACDATA/racdb/datafile/undotbs1.260.669487479
3    300      SYSAUX               NO      +RACDATA/racdb/datafile/sysaux.261.669487497
4    200      UNDOTBS2             YES     +RACDATA/racdb/datafile/undotbs2.263.669487539
5    5        USERS                NO      +RACDATA/racdb/datafile/users.264.669487561
List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       +RACDATA/racdb/tempfile/temp.262.669487527
在实例2主机查看:
rac2-> rman target / catalogrman/rman@mytest
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Nov 18 09:16:36 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: RACDB (DBID=667104169)
connected to recovery catalog database
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    400      SYSTEM               YES     +RACDATA/racdb/datafile/system.259.669487425
2    200      UNDOTBS1             YES     +RACDATA/racdb/datafile/undotbs1.260.669487479
3    300      SYSAUX               NO      +RACDATA/racdb/datafile/sysaux.261.669487497
4    200      UNDOTBS2             YES     +RACDATA/racdb/datafile/undotbs2.263.669487539
5    5        USERS                NO      +RACDATA/racdb/datafile/users.264.669487561
List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       +RACDATA/racdb/tempfile/temp.262.669487527
RMAN>

SQL> create tablespace rman_backup datafile '+RACDATA/' size 50M;
Tablespace created.
SQL> create user rman identified by rman default tablespace rman_backup temporary tablespace temp;
User created.
SQL> grant sysdba to rman;
Grant succeeded.

5.备份rac库及archivelog:
rac1->rman targetrman/rman@racdb1catalogrman/rman@mytest
run{
allocate CHANNEL ch00 type DISK CONNECT'sys/oracle@racdb1';
allocate CHANNEL ch01 type DISK CONNECT'sys/oracle@racdb2';
resync catalog;
backup database filesperset 10 format '/rmanset/full_%d%t%s%p'         tag 'fullbackup';
sql 'alter system archive log current';
BACKUP FORMAT '/rmanset/%d_arch_%s_%p_%h' ARCHIVELOG ALL delete all input;                                        
backup format '/rmanset/control_%d' current controlfile;
RELEASE CHANNEL ch00;                                                        
RELEASE CHANNEL ch01;                                                       
}
备份archivelog
run{
   allocate CHANNEL ch00 type DISK CONNECT'sys/oracle@racdb1';
   allocate CHANNEL ch01 type DISK CONNECT'sys/oracle@racdb2';
  resync catalog;
  sql 'alter system archive log current' ;
  backup filesperset 4    format '/rmanset/node2_%d_arch_%s_%p'
     (archivelog like '/racdb2_arch/%' delete input);
    backup format '/rmanset/control_%d' current controlfile;
}