一、描述:
- 本文主要讲解单实例RMAN异机恢复至RAC集群并升级数据库的相关事宜。
- 本文主要记录的是使用RMAN恢复ORACLE 11.2.0.3 至 11.2.0.4的详细步骤。
- 本文源端环境为Redhat 6.8 + Oracle 11.2.0.3 目标端环境为 Redhat 7.4 RAC + Oracle
11.2.0.4。 - 话不多说,进入实战。
二、准备环境
- 安装RAC的步骤就不在这里描述。
三、恢复
3.1 恢复spfile/pfile
-
首先从源端环境获取pfile,然后进行修改,以下为修改好的参数文件,可用于恢复目标库。
-
然后在节点1,编辑好参数文件:
-
下述代码加粗的表示需要修改或者注意的地方。
[oracle@golddb1 rman]$ cat /soft/rman/pfile_gold_20190918.ora
*.audit_file_dest=’/u01/app/oracle/admin/gold/adump’
*.audit_trail=‘NONE’
*.compatible='11.2.0.4.0’
*.control_files=’+DATA/GOLD/CONTROLFILE/control01.ctl’,’+DATA/GOLD/CONTROLFILE/control02.ctl’#Restore Controlfile
*.db_block_size=8192
*.db_domain=’’
*.db_name=‘gold’
*.db_unique_name=‘GOLD’
*.diagnostic_dest=’/u01/app/oracle’
*.dispatchers=’(PROTOCOL=TCP) (SERVICE=goldXDB)’
*.log_archive_dest_1='LOCATION=+ARCH/'
*.log_archive_dest_state_1=‘ENABLE’
*.log_archive_format=‘arch_%t_%s_%r.dbf’
*.open_cursors=300
*.processes=1000
*.remote_login_passwordfile=‘EXCLUSIVE’
*.sessions=1105
*.standby_file_management=‘AUTO’
*.undo_tablespace=‘UNDOTBS1’
[oracle@golddb1 rman]$
-
新建下列目录(用于审计文件/节点1、2均做)
mkdir -p /u01/app/oracle/admin/gold/adump
-
节点1启动实例进程
sqlplus / as sysdba
create spfile from pfile=’/soft/rman/pfile_gold_20190918.ora’;
startup nomount;
exit;
3.2 Restore控制文件
rman target /
run
{
allocate channel c1 type disk;
restore controlfile from '/soft/rman/20190712/cf_opt_c-3028359837-20190712-01';
release channel c1;
}
-
加载数据库
alter database mount;
-
注册备份恢复目录
rman target /
CATALOG START WITH ‘/soft/rman/20190712/’;
exit;
3.3 Restore 数据库
- 节点1编辑恢复脚本
more /home/oracle/scripts/restore.sh
source /home/oracle/.bash_profile
log_dir=/home/oracle/scripts/
dt=`date+%y%m%d%H%M%S`
export log_dir
export dt
$ORACLE_HOME/bin/rman target=/ log=$log_dir/log_restore_$dt.log <<EOF
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
set newname for database to '+DATA/';
restore database;
switch datafile all;
switch tempfile all;
}
EOF
- 启动后台任务
nohup sh restore.sh &
-
等待执行结果
-
或者使用查看进程
ps -ef |grep rman
waitting…
…
…
…
[oracle@golddb1 scripts]$ tail -f log_restore_.log
renamed tempfile 1 to +DATA/ in control file
renamed tempfile 2 to +DATA/ in control file
released channel: c1
released channel: c2
released channel: c3
released channel: c4
RMAN>
Recovery Manager complete.
until…
- 因为是异机恢复,需要考虑文件的路径问题,切记一定要在recover之前做datafile的rename,否则需要重新restore。
sqlplus / as sysdba
alter database rename file '/u02/redo/gold/redo04.log' to '+ARCH/GOLD/ONLINELO