在用rman进行异机恢复是,数据库版本要一致,操作系统版本必须统一平台。
rman target / cmdfile="/u01/rman/rmanfull.sql" log=/u01/rman/backuplog_$DATE <<eof
一、备份脚本:
run {
crosscheck archivelog all;
crosscheck backup;
delete noprompt obsolete;
delete noprompt expired backup;
backup format '/u01/bkdata/%T_%d_%s_%p_%u.dat' database ;
backup format '/u01/bkarch/%T_%d_%s_%p_%u.arc' archivelog all ;
backup format '/u01/bkdata/%T_%d_%s_%p_%u.ctl' current controlfile;
release channel d1;
release channel d2;
}
备份归档文件脚本
run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup format '/u01/bkarch/%T_%d_%s_%p_%u.arc' archivelog all delete all input;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
二、sftp到异机
sftp -P 30001 oracle@192.168.137.103
三、恢复控制文件
在恢复控制文件前把源库的参数文件及密码文件copy到目标库上
(create spfile from pfile;)
在目标库执行如下:
export ORACLE_SID=orclsid
rman target /
startup nomount;
restore controlfile from '/u01/bkdata/fulldb_ORCL_20240820_27172_1.ctl';
alter database mount;
}
四、恢复数据库
4.1注册备份集
RMAN>catalog start with '/u01/app/rmanbak';
4.2恢复数据文件及临时文件
rman target / log=/u01/app/log/restore1log_$DATE <<eof
run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
set newname for database to '/%b';
restore database;
switch datafile all;
switch tempfile all;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
eof
五、追加归档
nohup rman target / @/u01/app/scripts/rmanarch.sql log=/u01/app/scripts/log/recoarc.log
run{
restore archivelog from logseq 5122 until logseq ;
recover database;
}
六、修改redo 日志文件文件的路径
在源库上
sqlplus / as sysdba
set line 160
set pagesize 200
select 'alter database rename file '''||member||''' to ''/u01/oradata'||substr(member,instr(member,'/',-1))||''';'
七、关闭数据库开启目标库
sqlplus / as sysdba
alter database open resetlogs;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10201716/viewspace-3035209/ ,如需转载,请注明出处,否则将追究法律责任。