章三十一 RMAN 备份
概念
使用RMAN备份时, 目标数据库必须处于MOUNT或OPEN状态
备份集
只能用RMAN命令建立和转储
映像副本
单个数据文件,单个控制文件或单个归档文件的完整备份, 只能备份到磁盘, 不能备份到磁带
建立备份集
backup database format 'backup/%d_%s' ; 备份数据库:数据库名_备份集编号
backup tablespace system format 'backup/%d_%s'; 备份表空间
backup datafile 1 format 'backup/%d_%s'; 备份数据文件
backup current controlfile format 'backup/%d_%s.ctl'; 备份控制文件
backup spfile format 'backup/%d_%s.par'; 备份SPFILE
backup format='backup/%d_%s.arc' archivelog from time='sysdate-1' until time='sysdate'; 备份归档日志
backup copies 3 tablespace data01 format='backup1/%d_%s.dbf','backup2/%d_%s.dbf','backup3/%d_%s.dbf'; 建立多重备份
建立映像副本(使用copy 或backup as copy)f
backup as copy format='backup/demo.ctl' current controlfile;
copy current controlfile to 'backup/demo.ctl';
建立增量备份或累积备份
增量备份 0: 完全备份;1:备份变化数据块
backup incremental level 0 tablespace data01;
backup incremental level 1 tablespace data01;
累积备份
backup incremental level 1 cumulative tablespace data01;
章三十二 RMAN恢复
完全恢复
恢复数据库
run{
startup force mount
restore database;
recover database;
alter database open;
} //数据文件所在磁盘未损坏
run{
startup force mount
set newname for datafile 1 to 'newpath\system01.dbf';
restore database;
switch datafile all;
recover database;
alter database open;
} //数据文件所在磁盘损坏
恢复SYSTEM表空间的数据文件
run{
startup force mount;
restore tablespace system;
recover tablespace system;
alter database open;
}
恢复关闭后损害的其他数据文件
run{
startup force mount;
sql 'alter database datafile 4 offline';
alter database open;
restore datafile 4;
recover datafile 4;
sql 'alter database datafile 4 online';
}
数据块介质恢复
blockrecover device type disk datafile 5 block 21, 48. 148;
RMAN 不完全恢复
基于时间恢复
set nls_date_format=yyy-mm-dd:hh24:mi:ss
rman target sys/admin
run {
startup force mount;
set until time='2009-01-10:20:58:07';
restore database;
recover database;
sql 'alter database open resetlog';
}
基于SCN恢复
run{
startup force mount;
set until scn=511413;
restore database;
recover database;
sql 'alter database open resetlogs';
}
基于日志序列号恢复
run{
startup force mount;
set until sequence=6;
restore database;
recover database;
sql 'alter database open resetlogs';
}
基于备份控制文件恢复
set nls_data_format=yyyy-mm-dd:hh24:mi:ss
rman target sys/admin nocatalog
startup force nomount;
set dbid=3282656886;
restore controlfile from autobackup maxseq 6;
alter database mount;
run {
set until time='2008-01-10:21:58:07';
restore database;
recover database;
sql 'alter database open resetlogs';
}
阅读(1000) | 评论(0) | 转发(0) |