介绍了如何使用catalog方式做RMAN备份,以及如何取消以catalog方式做备份。
第一步:创建RMAN CATALOG表空间及用户。
[oracle@oel-01 ~]$ sqlplus / as sysdba
SQL> create tablespace catalog1 datafile '/u01/app/oracle/oradata/bys001/catalog1.dbf' size 50m ;
Tablespace created.
SQL> create user rmanuser identified by rmanuser default tablespace catalog1;
User created.
SQL> grant connect,resource,recovery_catalog_owner to rmanuser;
Grant succeeded.
SQL> select * from role_sys_privs where role='RECOVERY_CATALOG_OWNER';
ROLE PRIVILEGE ADM
------------------------------ ---------------------------------------- ---
RECOVERY_CATALOG_OWNER CREATE SYNONYM NO
RECOVERY_CATALOG_OWNER CREATE CLUSTER NO
RECOVERY_CATALOG_OWNER ALTER SESSION NO
RECOVERY_CATALOG_OWNER CREATE DATABASE LINK NO
RECOVERY_CATALOG_OWNER CREATE SESSION NO
RECOVERY_CATALOG_OWNER CREATE TABLE NO
RECOVERY_CATALOG_OWNER CREATE SEQUENCE NO
RECOVERY_CATALOG_OWNER CREATE PROCEDURE NO
RECOVERY_CATALOG_OWNER CREATE VIEW NO
RECOVERY_CATALOG_OWNER CREATE TYPE NO
RECOVERY_CATALOG_OWNER CREATE TRIGGER NO
11 rows selected.
第二步:注册数据库到RMAN CATALOG
[oracle@oel-01 ~]$ rman target
sys/[email protected]:1521/bys001 catalog rmanuser/rmanuser
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jun 19 14:28:59 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: BYS001 (DBID=2041679290)
connected to recovery catalog database
RMAN>
register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
第三步:查看是否注册
SQL> conn rmanuser/rmanuser
Connected.
SQL> select * from rc_database;
DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- -------- ----------------- ---------
2 4 2041679290 BYS001 1143629 16-JUN-13
第四步:到RMAN中执行全备备份
[oracle@oel-01 ~]$ rman target
sys/[email protected]:1521/bys001
catalog rmanuser/rmanuser
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jun 19 14:28:59 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: BYS001 (DBID=2041679290)
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> backup database;
Starting backup at 19-JUN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/bys001/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/bys001/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/bys001/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/bys001/undotbs01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/bys001/catalog1.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/bys001/users01.dbf
channel ORA_DISK_1: starting piece 1 at 19-JUN-13
channel ORA_DISK_1: finished piece 1 at 19-JUN-13
piece handle=/u01/app/oracle/flash_recovery_area/BYS001/backupset/2013_06_19/o1_mf_nnndf_TAG20130619T143220_8w2n3r2o_.bkp tag=TAG20130619T143220 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:12:38
Finished backup at 19-JUN-13
Starting Control File and SPFILE Autobackup at 19-JUN-13
piece handle=/backup/ctl_c-2041679290-20130619-08 comment=NONE
Finished Control File and SPFILE Autobackup at 19-JUN-13
第五步:取消使用CATALOG备份
这是使用list backup 查出来的信息,信息太多,只截了此次使用CATALOG备份的两个备份集。
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
545 Full 1.13G DISK 00:12:34 19-JUN-13
BP Key: 548 Status: AVAILABLE Compressed: NO Tag: TAG20130619T143220
Piece Name: /u01/app/oracle/flash_recovery_area/BYS001/backupset/2013_06_19/o1_mf_nnndf_TAG20130619T143220_8w2n3r2o_.bkp
List of Datafiles in backup set 545
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1305626 19-JUN-13 /u01/app/oracle/oradata/bys001/system01.dbf
2 Full 1305626 19-JUN-13 /u01/app/oracle/oradata/bys001/sysaux01.dbf
3 Full 1305626 19-JUN-13 /u01/app/oracle/oradata/bys001/undotbs01.dbf
4 Full 1305626 19-JUN-13 /u01/app/oracle/oradata/bys001/users01.dbf
5 Full 1305626 19-JUN-13 /u01/app/oracle/oradata/bys001/example01.dbf
6 Full 1305626 19-JUN-13 /u01/app/oracle/oradata/bys001/catalog1.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
559 Full 9.52M DISK 00:00:01 19-JUN-13
BP Key: 566 Status: AVAILABLE Compressed: NO Tag: TAG20130619T144500
Piece Name: /backup/ctl_c-2041679290-20130619-08
SPFILE Included: Modification time: 19-JUN-13
SPFILE db_unique_name: BYS001
Control File Included: Ckp SCN: 1306060 Ckp time: 19-JUN-13
RMAN> unregister database; 取消当前登陆的数据库注册到catalog
database name is "BYS001" and DBID is 2041679290
Do you really want to unregister the database (enter YES or NO)? y
database unregistered from the recovery catalog
RMAN> list backup;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 06/19/2013 15:15:22
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20001: target database not found in recovery catalog
RMAN> exit
Recovery Manager complete.
报错是因为登陆时是以指定catalog方式登陆,退出重新查询就可以了。
在SQLPLUS中查询
SQL> conn rmanuser/rmanuser
Connected.
SQL> select * from rc_database;
DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- -------- ----------------- ---------
2 4 2041679290 BYS001 1143629 16-JUN-13
SQL> select * from rc_database;
no rows selected
第六步:重新登陆RMAN查看备份集信息:
[oracle@oel-01 ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jun 19 15:15:48 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: BYS001 (DBID=2041679290)
RMAN> list backup;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
81 Full 9.52M DISK 00:00:03 19-JUN-13
BP Key: 81 Status: AVAILABLE Compressed: NO Tag: TAG20130619T110902
Piece Name: /backup/ctl_c-2041679290-20130619-02
SPFILE Included: Modification time: 18-JUN-13
SPFILE db_unique_name: BYS001
Control File Included: Ckp SCN: 1277256 Ckp time: 19-JUN-13
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
82 32.50K DISK 00:00:00 19-JUN-13
BP Key: 82 Status: AVAILABLE Compressed: NO Tag: BYS001-1
Piece Name: /backup/full/bys001arch_BYS001_818507657_87