RMAN备份2

1.Create catalog

2.Register database

3.Backup database Using catalog option

4.Maintenance catalog


实验环境:

Target  DB  SID=clonedb

Catalog DB SID=digoal


创建catalog分为三步:

1. create tablespace to store catalog's object

2. create rman user & grant privilege to it

3. create catalog on rman

 

 

Register target database

1.Connect to target using sysdba

2.Register database;

3.List incarnation;(查看target数据库的信息)

4.Report schema (查看target数据库的信息)

=================================================================================


uniread sqlplus / as sysdba

create tablespace tbs_rman datafile '/oradata/digoal/tbs_rman01.dbf' size 300m;

create user rmanuser identified by rman default tablespace tbs_rman temporary tablespace temp;

grant recovery_catalog_owner to rmanuser;

conn rmanuser/rman

select * from session_privs;(查看rman用户的权限,发现没有对表空间进行操作的权限)

 

 

 

conn /as sysdba

alter user rmanuser quota unlimited on tbs_rman;(rmanuser用户可以对tbs_rman表空间具有写权限)

conn rmanuser/rman

select * from session_privs;

select * from session_roles;

在rman命令行下注册和创建catalog

shell>rman catalog rmanuser/rman (rmanuser用户必须有RECOVERY_CATALOG_OWNER权限)

create catalog tablespace tbs_rman;

catalog已经创建好了


connect target sys/oracle@clonedb;(必须用sys角色来进行连接)
register database;

List incarnation;(列出target db的信息)

Report schema (目标库有那些表空间和临时文件)


List backup; 查看以前做过的一些备份

List copy;   查看一下归档日志

=====================================================================================
Backup target database (备份目标数据库)

1. Full backup (全备份)

2. Incremental backup (增量备份)0,1,2级别

3. Differential&cumulative(差异增量和累计增量)

4. backup tablespace (备份表空间)

5. backup datafile (备份数据文件)

6. backup controlfile&spfile(备份控制文件和参数文件)

7. backup archivelog file (备份归档日志文件)

8. backup as copy (备份影像拷贝)


1.1
 run{
allocate channel d1 device type disk;
backup as compressed backupset(使用压缩)
format='/rmanbak/full_%d_%U'
tag='fullbak'
channel=d1
database plus archivelog delete input;(在run中自动释放channel)
} (备份全库,备份归档日志,归档日志备完用户删除归档日志)


crosschek copy (校验归档日志)

controlfile 和spfile在备份system表空间的时候,会自动备份(在rman的输入信息中可以看到)

 

2. 增量备份
 run{
  allocate channel d1 device type disk;
  backup as compressed backupset (在10g以后,才有压缩备份)
  incremental level=0
  format='/rmanbak/inc0_%d_U'
  tag='inc0'
  channel=d1
  database ;
  release channel d1;
}

查看一下备份细节
list backup summary;


3.做一个级别为1的备份

 run{
 allocate channel d1 device type disk;
 backup as  compressed backupset
 incremental level=1
 format='/rmanbak/inc1_%d_%U'
 tag='inc1'
 channel=d1
 database;
 release channel d1;}


list backup summary;

list backup by file;


3.累计型的增量备份;
 run{
 allocate channel d1 device type disk;
 backup as  compressed backupset
 incremental level=1 cumulative
 format='/rmanbak/cum1_%d_%U'
 tag='cum1'
 channel=d1
 database;
 release channel d1;}


4.备份表空间

  run{
  allocate channel d1 device  type disk;
  backup as compressed backupset
  format='/rmanbak/tbs_users%d_%U'
  tag='tbs'
  channel=d1
  tablespace users; //多个表空间 tablespace users,center,system;
  release channel d1;
}

list backupset summary;

5.备份数据文件
run{
 allocate channel d1 device type disk;
 backup as compressed backupset
 format='/rmanback/df_%d_%U'
 tag='dfile'
 datafile 1;//1表示系统表空间
 release channel d1;
 }

 list backupset tag='DFILE';

6.如何备份archivelog

 crosscheck  archivelog all

 sql " alter system switch logfile";//目标数据库切换日志

 
 list achivelog all;

 
什么样的archivelog需要,什么样的不需要

list backupset (SCN)


run {
 allocate channel d1 device type disk;
 backup as compressed backupset format='/rmanbak/arc_%d_%U'
 tag='arch' channel=d1 archivelog from scn 1219672 ; release channel d1;}


list backupset


7. backup copy

run{
 allocate channel d1 device type disk;
 backup as copy
 format='/rmanbak/copy_%d_%U'
 tag='copybak'
 channel=d1
 database(datafile 1) //databahannel d1
}

8如何查看备份

RMAN> list backupset . (查看) 点号有很多意思(by,backed,completed,device,integer,like ,of reccoverable


9. report.(schema device,need,obsolete)

10.crosscheck (backupset) 检查备份是否删除

11. change backupset

12. validate backupset (检验备份集是否可以用来恢复)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值