rman技术速查手册
一、备份方案:
采用多级备份是为了减少了恢复所需要的时间和减少每天备份所需要的时间,而又保证系统有很好的恢复性。
以下是一种建议的方案:
每半年做一个数据库的全备份(包含只读表空间)
每个月做一次零级备份(不包含只读表空间)
每个星期做一次一级备份
每天做一个二级备份
任何表空间改成只读状态后做一个该表空间的备份。
当需要时(如四个小时归档文件系统就要接近满了)备份归档文件
1、数据库全备份脚本:
run {
allocate channel c1 type disk;
backup full tag 'dbfull' format '/opt/backup/full_%d_%u' (database include current controlfile);
sql 'alter system archive log current' ;
backup format '/opt/backup/archivelog_%d_%u' (archivelog all);
release channel c1;
}
2、零级备份:
run {
allocate channel c1 type disk;
backup incremental level 0 filesperset 5 tag 'dbL0' format '/opt/backup/ora_0_%d_%u' (database include current controlfile);
sql 'alter system archive log current' ;
backup format '/opt/backup/archivelog_%d_%u' (archivelog all);
release channel c1;
}
3、一级备份:
run {
allocate channel c1 type disk;
backup incremental level 1 filesperset 5 tag 'dbL1' format '/opt/backup/ora_0_%d_%u' (database include current controlfile);
sql 'alter system archive log current' ;
backup format '/opt/backup/archivelog_%d_%u' (archivelog all);
release channel c1;
}
4、二级备份:
run {
allocate channel c1 type disk;
backup incremental level 2 filesperset 5 tag 'dbL2' format '/opt/backup/ora_0_%d_%u' (database include current controlfile);
sql 'alter system archive log current' ;
backup format '/opt/backup/archivelog_%d_%u' (archivelog all);
release channel c1;
}
5、表空间备份脚本(以users表空间为例):
run {
allocate channel c1 type disk;
backup tag 'tsusers' format '/opt/backup/ora_0_%d_%u' tablespace users;
sql 'alter system archive log current' ;
backup format '/opt/backup/archivelog_%d_%u' (archivelog all);
release channel c1;
}
6、归档文件备份脚本:
run {
allocate channel c1 type disk;
backup format '/opt/backup/archivelog_%d_%u' (archivelog all);
release channel c1;
}
二、RMAN恢复案例
1 、丢失全部数据文件,控制文件、日志文件必须存在
模拟介质损坏:删除所有dbf文件
启动数据库:startup mount
恢复语句:
run{
allocate channel c1 type disk;
restore database;
recover database;
sql 'alter database open';
release channel c1;
}
注意:Oracle永远不会备份使用临时文件的TEMPORARY表空间,因为临时表空间包含的只是暂时
性的数据,根本不必还原。不过在还原后数据字典中还是有临时表空间的相关信息,你只要
简单的重建一个临时表空间,设置其为缺省临时表空间,再把以前的临时表空间删除即可。
SQL> create temporary tablespace temp2 tempfile 'd:oracleoradataoradbtemp02.dbf' size 100M;
SQL> alter database default temporary tablespace temp2;
SQL> drop tablespace temp including contents and datafiles;
2、丢失非系统数据文件恢复
模拟介质损坏:删除users01.dbf文件
启动数据库:startup mount
恢复语句:
run {
allocate channel c1 type disk;
&nbs
- 发表评论
-
- 最新评论 更多>>