RMAN 备份

简介:

1、RMAN执行脱机-全部-完整备份

RMAN> run {

2> shutdown immediate;

3> startup mount;

4> allocate channel d1 type disk;

5> backup as backupset database format '/oraclebk/offline_full_whole.bak';

6> alter database open;

7> }


2、RMAN脚本

#脚本offline_full_whole.rman内容:

run {

shutdown immediate;

startup mount;

allocate channel d1 type disk;

backup as backupset database format '/oraclebk/offline_full_whole_%T_%U.bak';

alter database open;

}

#执行RMAN脚本

su - oracle

rman target / @offline_full_whole.rman


3、RMAN执行在线-全部-完整备份

run {

allocate channel t1 type disk;

backup as compressed backupset filesperset 4 database format '/oraclebk/online_full_whole_%T_%U.bak';

}


4、增量备份

backup incremental level 0 database;

backup incremental level 1 database;

注:做增量备份的前提,是需要一个基准备份,所有的增量都是针对这个基准来说的。要不然,增量备份无从谈起。增量备份使用INCREMENTAL LEVEL=integer关键字指定。integer可以是0到4之间的任意整数。必须将0 级备份作为增量策略的基础备份。0 级增量备份在内容上与完全备份相同,但与完全备份不同的是,0 级备份被看作是增量策略的一部分。如果在运行1 级或更高级别的备份时,0 级备份不存在,RMAN 会自动制作0 级备份。


5、查看RMAN配置信息

show all;


6、非归档模式下还原数据库

run {

shutdown abort;

startup mount;

restore database;

alter database open resetlogs;

}


7、冲刷高速缓冲区

alter system flush buffer_cache;


8、不完整恢复

run {

shutdown immediate;

startup mount;

set until time = "to_date('26-12-17 15:20:00','dd-mm-yy hh24:mi:ss')";

restore database;

recover database;

alter database open resetlogs;

}


9、RMAN恢复报一下错误

RMAN> restore database;


Starting restore at 26-DEC-17

using channel ORA_DISK_1


channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2017_12_26/o1_mf_nnndf_TAG20171226T170208_f4440jv1_.bkp

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 12/26/2017 17:03:30

ORA-19870: error while restoring backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2017_12_26/o1_mf_nnndf_TAG20171226T170208_f4440jv1_.bkp

ORA-19573: cannot obtain exclusive enqueue for datafile 1


处理方法:

SQL> shutdown immediate;

SQL> startup mount;


注意:使用RMAN恢复时需要将数据库启动到mount状态



     本文转自1321385590 51CTO博客,原文链接:http://blog.51cto.com/linux10000/2054838 ,如需转载请自行联系原作者



相关文章
|
网络协议 Unix
dg rman 增量备份恢复
dg rman 增量备份恢复
145 0
|
数据库
rman 异机恢复
rman 异机恢复
123 0
|
监控
rman 恢复部分归档日志
rac 数据库在恢复部分归档日志的时候,需要指定数据库的线程编号。
1902 0
|
SQL otter 关系型数据库
|
SQL Oracle 关系型数据库
|
SQL Oracle 关系型数据库
|
Oracle 关系型数据库 数据库
|
Oracle 关系型数据库 Shell