Oracle之RMAN备份异机恢复(单机到单机)
Oracle之RMAN备份异机恢复(单机到单机)
一、环境说明
系统版本 | 主机名 | DB版本 | DB名 | 实例名 | Public-IP | |
---|---|---|---|---|---|---|
正式库 | Redhat9.5 | lemon | Enterprise 19.25 | lemon | lemon | 192.168.118.10 |
测试库 | Redhat9.5 | lemon1 | Enterprise 19.25 | lemon | lemon | 192.168.118.11 |
二、正式库进行RMAN备份
RMAN全备脚本
cat /home/oracle/scripts/rman_full.sh
#!/bin/bash
source ~/.bash_profile
TODAY=`date +%Y-%m-%d`
rman target / nocatalog <<EOF
spool log to '/home/oracle/scripts/logs/$TODAY.full_backup.log';
run{
allocate channel c1 device type disk;
backup as compressed backupset filesperset 2 database format '/backup/level0_%d_%t_%s_%p' tag 'L0';
sql 'alter system archive log current';
backup as compressed backupset archivelog all format '/backup/arc_%t_%s';
backup current controlfile format '/backup/cntrl_%s_%p_%s';
release channel c1;
}
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt obsolete;
EOF
执行备份脚本
sh /home/oracle/scripts/rman_full.sh
查看备份log
备份正常,查看备份文件
正式库生成参数文件
三、将正式库备份与参数文件拷贝到测试库
scp命令传输
传输备份文件:
传输参数文件
测试库文件检查
检查备份文件
检查参数文件
四、测试库异机恢复
编辑参数文件
创建spfile,将数据库启动到nomount状态
create spfile from pfile='/home/oracle/pfile/ora';
startup nomount;
恢复控制文件,将数据库启动到mount状态
restore controlfile from '/backup/cntrl_19_1_19';
注册备份集
catalog start with '/backup/';
#crosscheck核对数据文件备份集:
crosscheck backup;
restore database
run{
allocate channel t1 type disk;
allocate channel t2 type disk;
restore database;
switch datafile all;
release channel t2;
release channel t1;
}
recover database
recover database;
开启数据库
alter database open resetlogs;
检查数据库
select name,open_mode from v$database;
select file_name from dba_temp_files;
select member from v$logfile;
show parameter name
五、验证数据
原文地址:https://blog.csdn.net/a2279338659/article/details/145122510
免责声明:本站文章内容转载自网络资源,如侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!