设为首页 加入收藏

TOP

Oracle数据库rman备份计划及恢复(一)
2015-12-15 22:17:57 来源: 作者: 【 】 浏览:16
Tags:Oracle 数据库 rman 备份 计划 恢复

1.rman完全恢复的前提条件:历史的datafile,controlfile和spfile备份,加上完整的archivelog和完好的redolog。


2.rman备份脚本:


a.RMAN 0级备份命令:


run{?
allocate channel c1 type disk;?
allocate channel c2 type disk;?
allocate channel c3 type disk;?
backup incremental level 0 tag? 'level0'? format "E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\RFDB_level_0_%u_%s_%p"? as compressed backupset
database;?
sql "alter system archive log current";?
backup filesperset 3 format "E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\arch_%u_%s_%p_%c"?
archivelog all delete input; #备份归档可选,可以单独定期备份?
release channel c1;?
release channel c2;?
release channel c3;?
}?


b.RMAN 1级备份命令:


run{?
allocate channel c1 type disk;?
allocate channel c2 type disk;?
allocate channel c3 type disk;?
backup incremental level 1 tag? 'level1' format 'E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\RFDB_level_1_%u_%s_%p'? as compressed backupset
database;?
sql 'alter system archive log current';?
backup filesperset 3 format 'E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\arch_%u_%s_%p'?
archivelog all delete input; #备份归档可选,可以单独定期备份?
release channel c1;?
release channel c2;?
release channel c3;?
}?


c.rman删除备份命令(在保留最近一天备份的情况下,删除其他备份):


DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 1 DAYS;?


d.操作系统层面运行rman备份或删除命令:


rman target sys/rf4rfvbgt56yhn@rfdb nocatalog CMDFILE 'D:\app\rman\rman_file\level_0.txt' log=E:\recovery_area\rfdb\rfdb\AUTOBACKUP\rman_dir\log\rman_level_0.log


3.rman恢复


a.拷贝datafile,controlfile和spfile的rman备份,以及完整的archivelog和完好的redolog文件到新的数据库


export ORACLE_SID=rfdb
rlwrap? rman target /


c.启动一个伪实例:


RMAN> startup nomount


connected to target database (not started)
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db1/dbs/initrfdb.ora'


starting Oracle instance without parameter file for retrieva l of spfile
Oracle instance started


Total System Global Area? ? 1068937216 bytes


Fixed Size? ? ? ? ? ? ? ? ? ? 2260088 bytes
Variable Size? ? ? ? ? ? ? ? 281019272 bytes
Database Buffers? ? ? ? ? ? 780140544 bytes
Redo Buffers? ? ? ? ? ? ? ? ? 5517312 bytes


d.在伪实例下恢复spfile文件(必须要指定rman的备份片):


RMAN> restore spfile from "/u01/ora_bak/ora_bak/autobackup/2015_12_07/o1_mf_s_897845728_c6bnq1rq_.bkp";


Starting restore at 14-DEC-15
using channel ORA_DISK_1


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/ora_bak/ora_bak/autobackup/2015_12_07/o1_mf_s_897845728_c6bnq1rq_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 14-DEC-15


e.关闭伪实例,用spfile文件启动至nomount状态:


RMAN> shutdown abort


Oracle instance shut down


RMAN> startup nomount


connected to target database (not started)
Oracle instance started


Total System Global Area? ? 1068937216 bytes


Fixed Size? ? ? ? ? ? ? ? ? ? 2260088 bytes
Variable Size? ? ? ? ? ? ? ? 910164872 bytes
Database Buffers? ? ? ? ? ? 150994944 bytes
Redo Buffers? ? ? ? ? ? ? ? ? 5517312 bytes


f.恢复控制文件(必须要指定rman的备份片,备份片应该和spfile的恢复片是同一个):


RMAN> restore controlfile from "/u01/ora_bak/ora_bak/autobackup/2015_12_07/o1_mf_s_897845728_c6bnq1rq_.bkp";


Starting restore at 14-DEC-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1146 device type=DISK


channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/ATEST/controlfile/o1_mf_c5fr9b0h_.ctl
output file name=/u01/app/oracle/fa

首页 上一页 1 2 3 4 5 6 下一页 尾页 1/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇深入理解DB2表空间(Tablespace) 下一篇Oracle查看对象信息

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: