源机器是Oracle ODA一体机,2节点RAC系统,目标机器为单机。Oracle版本为11.2.0.4。

源机器上获取必要的文件

源机器上已经存在RMAN的备份数据,可以查看备份位置

$ rman target /
RMAN> list backup

... 如下信息显示了数据文件备份位置
Piece Name: /backup/rman_full_bak/bak_arc_20220114_p70j7k4b_1_1

... 如下信息显示了SPFILE、Control File是否包含及位置
Piece Name: /u03/app/oracle/fast_recovery_area/ORCL/autobackup/2022_01_14/o1_mf_s_1093914812_jy0qfz6p_.bkp
...

准备数据文件

在目标机器上建立备份数据目录

# mkdir /bak
# chown -R oracle:oinstall /bak
# su - oracle
$ mkdir -p /bak/oradata/orcl

把"/backup/rman_full_bak/"中的数据文件和归档备份文件传输到目标机器

scp /backup/rman_full_bak/bak_*_20220214* oracle@192.168.20.67:/bak/oradata/orcl/

把控制文件传输到目标机器

scp /u03/app/oracle/fast_recovery_area/ORCL/autobackup/2022_02_14/o1_mf_s_1096593101_k0lgygpn_.bkp oracle@192.168.20.67:/bak/oradata/

准备zone文件

缺少zone文件会产生"ORA-01804: failure to initialize timezone information"错误及"ORA-00600"错误

SQL> col name format a30
SQL> col value$ format a10
SQL> select NAME, VALUE$ from SYS.PROPS$ where NAME like 'DST_%_TT_VERSION';
NAME                           VALUE$
------------------------------ ----------
DST_PRIMARY_TT_VERSION         31
DST_SECONDARY_TT_VERSION       0

$ scp $ORACLE_HOME/oracore/zoneinfo/timez*_31.dat oracle@192.168.20.67:/bak/

在目标服务器上恢复

准备timezone文件

$ cp /bak/timez*.dat $ORACLE_HOME/oracore/zoneinfo/

初始化目录

mkdir -p /u01/app/oracle/oradata/
mkdir -p /u01/app/oracle/redo/
mkdir -p /u01/app/oracle/fast_recovery_area/
mkdir -p /u01/app/oracle/admin/orcl/adump/

初始pfile文件

cat > /bak/oradata/init.orcl.ora << EOF
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.4'
*.control_files='/u01/app/oracle/oradata/control.orcl.01.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata/'
*.db_create_online_log_dest_1='/u01/app/oracle/redo/'
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area/'
*.DB_RECOVERY_FILE_DEST_SIZE=4G
*.db_unique_name='orcl'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
EOF

启动数据库

# su - oracle
$ sqlplus / as sysdba
SQL> startup nomount pfile='/bak/oradata/init.orcl.ora';

恢复控制文件

$ rman target /
RMAN> restore controlfile from '/bak/oradata/o1_mf_s_1096593101_k0lgygpn_.bkp';
RMAN> alter database mount;

修改文件路径

有很多文档中提到需要人工处理,实际使用中,貌似Oracle在恢复中可以自己处理并转换。

目前为止系统中是旧的文件路径:

SQL> select name from v$datafile union all select name from v$tempfile union all select member from v$logfile;

恢复数据库

RMAN> 
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;

catalog start with '/bak/oradata/orcl/';
crosscheck backup;

使用RMAN恢复并重定向文件

RMAN> restore database;
RMAN> recover database;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/15/2022 17:52:00
RMAN-06054: media recovery requesting unknown archived log for thread 2 with sequence 28494 and starting SCN of 5992769821705
RMAN> recover database until scn=5992769821705;

再次查看文件路径,并确认redo日志路径是否正常

$ sqlplus / as sysdba
SQL> select name from v$datafile union all select name from v$tempfile union all select member from v$logfile;

启动数据

SQL> alter database open resetlogs;
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database open;
SQL> create spfile from pfile='/bak/oradata/init.orcl.ora';
SQL> create pfile='/bak/oradata/init.orcl.2.ora' from spfile;

失败重来

rm -rf /u01/app/oracle/oradata/*
rm -rf /u01/app/oracle/redo/*
rm -rf /u01/app/oracle/fast_recovery_area/*
rm -rf /u01/app/oracle/admin/orcl/adump/*
reboot

参考资料

RMAN备份策略与异机恢复一例(续篇)

ORA 600 [qcisSetPlsqlCtx:tzi init]

[ 编辑 | 历史 ]
最近由“jilili”在“2022-02-14 16:09:05”修改