备份方案:
星期7 增量0级备份 (每天1点备份)
星期1 2级 (相对于7的增量备份)
星期2 2级 (相对于1的增量备份)
星期3 1级 (7-2的3天增量备份)
星期4 2级 3的增量
星期5 2级 4的增量
星期6 2级 5的增量
如果星期3,12点挂了,该如何恢复?
需要7的0级备份和3的1级备份,还有3的1点-12点的归档日志和归档前的联机日志
-------------------------------------------------------
(已上面的备份方案写相应脚本)
通过脚本,在RMAN中执行备份
c001通道名称(用完之后释放) type介质 fileperset备份集
level 0脚本
run {
allocate channel c001 type disk format '/opt/app/rman/full0_%U.dbf';
backup
incremental level 0
skip inaccessible
tag full0_sytong1
filesperset 2
database;
release channel c001;
}
level 1脚本
run {
allocate channel c001 type disk format '/opt/app/rman/level1_%U.dbf';
backup
incremental level 1
skip inaccessible
tag level1_sytong1
filesperset 5
database;
release channel c001;
}
level 2脚本
run {
allocate channel c001 type disk format '/opt/app/rman/level2_%U.dbf';
backup
incremental level 2
skip inaccessible
tag level2_sytong1
filesperset 5
database;
release channel c001;
}
归档日志脚本
run {
allocate channel c001 type disk format '/opt/app/rman/arch_%U.dbf';
backup
skip inaccessible
tag arch_sytong1
filesperset 5
archivelog all;
release channel c001;
}
-------------------------------------------------
备份方案:
full0 (level0) 每周日22:00开始
level1 (level1) 每周三23:00开始
level2 (level2) 周一、二、四、五23:30开始
arch.sh 每天20:00开始
cd /home/oracle/rman
共8个文件:full0.rman/level1.rman/level2.rman/arch.rman
full0.sh/level1.sh/level2.sh/arch.sh
$ vi full0.rman (level1.rman/level2.rman/arch.rman类似创建)
run {
allocate channel c001 type disk format '/opt/app/rman/full0_%U.dbf';
backup
incremental level 0
skip inaccessible
tag full0_sytong1
filesperset 2
database;
release channel c001;
}
$ vi full0.sh (full0.sh/level1.sh/level2.sh/arch.sh类似创建)
su - oracle -c "rman target / cmdfile=/home/oracle/rman/full0.rman"
# sh /home/oracle/rman/full0.sh (直接运行脚本)执行.sh调用.rman中的语句
rman> list backup; (查看备份记录)
[root@stu133 ~]# crontab -e
* 22 * * 0 /bin/bash /home/oracle/rman/full0.sh (0代表星期天)
* 23 * * 3 /bin/bash /home/oracle/rman/level1.sh
30 23 * * 1,2,4,5 /bin/bash /home/oracle/rman/level2.sh
30 23 * * * /bin/bash /home/oracle/rman/arch.sh
----------------------------------------------
实验:数据库被破坏,通过之前的备份文件恢复
ll -st (按时间戳排序)
破坏
1 mv spfile pfile,
2 mkdir /opt/app/oracle/oradata/sytong2
3 mv /opt/app/oracle/oradata/sytong1 /opt/app/oracle/oradata/sytong2
恢复
1 退出rman重新登录
rman> startup
RMAN> restore spfile from '/opt/app/rman/full0_1potol3n_1_1.dbf';(==补充:可能无法restore,需要通过rman起dummy实例)
rman> restore controlfile from '/opt/app/rman/full0_1potol3n_1_1.dbf';
SQL> startup force
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
日志比较旧了,强制开启数据库
SQL> alter database open resetlogs;
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/opt/app/oracle/oradata/sytong1/system01.dbf'
RMAN> restore database; 修复
RMAN> recover database; 介质还原
recover会报错,不知什么原因,备份之前切换过归档日志,/opt/app/archive目录下有日志
starting media recovery
archive log thread 1 sequence 17 is already on disk as file /opt/app/archive/1_17_832868026.dbf
archive log filename=/opt/app/archive/1_17_832868026.dbf thread=1 sequence=17
unable to find archive log
archive log thread=1 sequence=18
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/11/2014 08:11:45
RMAN-06054: media recovery requesting unknown log: thread 1 seq 18 lowscn 2969105
SQL> startup force; (重启数据库成功)
阅读(2600) | 评论(0) | 转发(0) |