RMAN_学习笔记3_RMAN Catalog恢复目录

2014-12-23 Created By BaoXinjian

一、创建恢复目录


创建恢复目录一般分为三大步骤

Step1. 创建存放恢复目录的数据库(或使用已存在的数据库)

Step2. 创建恢复目录的的所有者

Step3. 创建恢复目录

 

二、创建恢复目录案例

在存储恢复目录的数据库创建表空间用于存储恢复目录schema及恢复目录数据(本文使用已经创建好的数据库catadb来存储恢复目录)

Step1. 创建rman恢复目录表空间

SQL> create tablespace tbs_rman datafile '/data/oracle/odellprod/catadb/tbs_rman01.dbf' size 200m autoextend on; 
Tablespace created. 

Step2. 创建rman schema        

SQL> create user rman identified by rman temporary tablespace temp default tablespace tbs_rman quota unlimited on tbs_rman; 

Step3. 角色授予

Step3.1 授予角色

SQL> grant recovery_catalog_owner to rman; 
Grant succeeded.

Step3.2 使用rman链接

SQL> conn rman/rman 
Connected.

Step3.3 查看privsilge      

SQL>  select * from session_privs;

PRIVILEGE
----------------------------------------
CREATE SESSION
ALTER SESSION
CREATE TABLE
CREATE CLUSTER
CREATE SYNONYM
CREATE VIEW
CREATE SEQUENCE
CREATE DATABASE LINK
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE

11 rows selected.

Step3.4 查看roles

SQL>  select * from session_roles;

ROLE
------------------------------
RECOVERY_CATALOG_OWNER

Step4. 连接到恢复目录

RMAN> connect catalog rman/rman@catadb  
connected to recovery catalog database

Step5. 创建恢复目录

RMAN> create catalog tablespace tbs_rman; 
recovery catalog created
[oracle@odellprod ~]$ rman target sys/oracle@odellprod catalog rman/rman@catadb   --连接到目标数据库及恢复目录
connected to target database: ORCL (DBID=1260850162)
connected to recovery catalog database

Step6. 将目标数据库注册到恢复目录 

RMAN> register database;      
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

 

、基于恢复目录的备份


1.查看相关信息

RMAN> list incarnation;            --列出备份

RMAN> crosscheck copy;         --校验copy

RMAN> delete expired copy;     --删除过期的copy 

2.全备

RMAN> run{
allocate channel ch1 device type disk;
backup as compressed backupset
database plus archivelog delete input
format='/u01/app/oracle/bk/rmbk/Whole_%d_%U'
tag='whole_bak';
release channel ch1;}

3.增量备份(0级)

RMAN> run{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
backup as compressed backupset
incremental level 0
database plus archivelog delete input
format='/u01/app/oracle/bk/rmbk/Inc_0_%d_%U'
tag='inc_0';
release channel ch1;
release channel ch2;}  

RMAN> list backup summary;

4.增量备份(1级)

RMAN> run{                                 
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
backup as compressed backupset
incremental level 1 database
format='/u01/app/oracle/bk/rmbk/Inc_1_%d_%U'
tag='inc_1';
release channel ch1;
release channel ch2;}

RMAN> list backup by file;

5.累计增量备份(1级)

RMAN> run{
allocate channel ch1 device type disk;
backup as compressed backupset
incremental level 1 cumulative database
format '/u01/app/oracle/bk/rmbk/Cum_1_%d_%U'
tag='cum_1';
release channel ch1;}

6.备份表空间

RMAN> run{
allocate channel ch1 device type disk;
backup as compressed backupset
tablespace users,example
format='/u01/app/oracle/bk/rmbk/tbs_%d_%U'
tag='tbs';

RMAN> list backupset tag=tbs;

7.备份数据文件

RMAN> run{
allocate channel ch1 device type disk;
backup as compressed backupset
datafile 3
format='/u01/app/oracle/bk/rmbk/df_%d_%U'
tag='df';
release channel ch1;}

8.备份归档日志

备份归档日志前,建议先使用crosscheck校验一下

crosscheck通常用于检查备份是否被删除,如果删除将会打上删除标签

RMAN> crosscheck archivelog all;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=148 devtype=DISK
validation succeeded for archived log
archive log filename=/u01/app/oracle/oradata/orcl/arch/log_1_117_733069427.arc recid=111 stamp=733171369
crosschecked 1 objects

RMAN> sql 'alter system switch logfile';

RMAN> sql 'alter system switch logfile';

RMAN> list archivelog all;

9.基于SCN来备份归档日志

RMAN> run{
allocate channel ch1 device type disk;
backup as compressed backupset
archivelog from scn 848043
format='/u01/app/oracle/bk/rmbk/arc_%d_%U'
tag='arc';
release channel ch1;}

 10.镜像备份

RMAN> run{
allocate channel ch1 device type disk;
backup as copy datafile 1,4
format '/u01/app/oracle/bk/rmbk/df_%d_%U'
tag 'copybak';
release channel ch1;}

11.其它

        RMAN> crosscheck backupset;

        RMAN> change backupset 1

        RMAN> validate backupset

        RMAN> validate backupset 635;

 

Thanks and Regards

转载:乐沙弥大神 - http://blog.csdn.net/leshami/article/details/6043649

posted on 2015-04-02 19:44  东方瀚海  阅读(608)  评论(0编辑  收藏  举报