RMAN catalog
的创建和使用
一般用
rman target /
登录后执行的备份在使用
list backup
都会提示:
using target database control file instead of recovery catalog
,即“使用目标数据库控制文件替代恢复目录”,无
catalog
数据库时,所有的备份信息都存储在控制文件里。随着备份的增多控制文件的大小也会不断增大,同时,备份策略受
control_file_record_keep_time
参数影响,因此在
nocatalog
方式下,备份控制文件显得非常重要。
而
catalog
方式是不存在以上问题。
1、创建catalog数据库:
创建
catalog
数据库需要以下几步:
1、
创建恢复目录数据库
2、
创建所有者并授权
3、
创建恢复目录
创建好恢复目录数据库后,可创建单独的表空间存储恢复目录数据也可用所有者默认的
users
表空间。
SQL>create user rman identified by rman;
----
创建
rman
用户
SQL>grant connect,resource,recovery_catalog_owner to rman;
----
角色授予
SQL>conn rman/rman@rman
----
以
rman
用户登录
catalog
数据库
SQL> select * from session_privs;
PRIVILEGE
----------------------------------------
CREATE SESSION
ALTER SESSION
UNLIMITED TABLESPACE
CREATE TABLE
CREATE CLUSTER
CREATE SYNONYM
CREATE VIEW
CREATE SEQUENCE
CREATE DATABASE LINK
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE
CREATE OPERATOR
CREATE INDEXTYPE
----rman
用户权限
C:\>rman target sys/admin@orcl catalog rman/rman@rman
---orcl
目标数据库,
rman
恢复目录数据库
Recovery Manager: Release 10.2.0.1.0 - Production on Sun May 13 20:17:22 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: HUNT (DBID=719233105)
connected to recovery catalog database
RMAN> create catalog
---
创建恢复目录
RMAN> register database
---
注册目录数据库
RMAN>resync catalog
---
同步控制文件信息,
list backup
可看到之前的备份信息。有时无法看到之前的备份信息,当前备份的也没有,重建控制文件即可解决。控制文件重建以后,新控制文件中已无之前备份信息,因此无法同步到
catalog
数据库,可使用
catalog backuppiece '
实际目录
'
将丢失的备份信息注册到
catalog
数据库中。
2、备份数据库:
---
增量
0
级备份:
RMAN> run {
2> allocate channel ch01 device type disk;
3> allocate channel ch02 device type disk;
4> allocate channel ch03 device type disk;
5> sql 'alter system archive log current';
6> backup as compressed backupset incremental level 0 database format='e:\rman\Oracle10g_%d_data_0_%T_%U.rman' tag='Level_0_data';
7> sql 'alter system archive log current';
8> backup archivelog all delete all input format ='e:\rman\Oracle10g_%d_archivelog_0_%T_%U.rman' tag='Level_0_archivelog';
9> release channel ch01;
10> release channel ch02;
11> release channel ch03;
12> }
--
增量
1
级备份:
RMAN> run {
2> allocate channel ch01 device type disk;
3> allocate channel ch02 device type disk;
4> allocate channel ch03 device type disk;
5> sql 'alter system archive log current';
6> backup as compressed backupset incremental level 1 database format='e:\rman\Oracle10g_%d_data_0_%T_%U.rman' tag='Level_1_data';
7> sql 'alter system archive log current';
8> backup archivelog all delete all input format ='e:\rman\Oracle10g_%d_archivelog_0_%T_%U.rman' tag='Level_1_archivelog';
9> release channel ch01;
10> release channel ch02;
11> release channel ch03;
12> }
--
备份数据文件:
RMAN> run {
2> allocate channel ch01 device type disk;
3> allocate channel ch02 device type disk;
4> backup as compressed backupset datafile 4,5,6 format ='e:\rman\Oracle10g_%d_datafile456_0_%T_%U.rman' tag='datafile456';
5> release channel ch01;
6> release channel ch02;
7> }
--
备份表空间:
RMAN> run {
2> allocate channel ch01 device type disk;
3> allocate channel ch02 device type disk;
4> backup as compressed backupset tablespace system,sysaux format ='e:\rman\Oracle10g_%d_tbs12_0_%T_%U.rman' tag='tbs12';
5> release channel ch01;
6> release channel ch02;
7> }