本文通过将Oracle 10g RAC RMAN的完整的备份进行异机恢复的过程,可以对在恢复的过程中可以发现备份时的一些问题。比如规档日志的冗余,控制文件与参数文件的自动备份的利用等,本示例是拿了rman的备份集进行备份的,所以在最后的启动数据库的过程中出现了问题,提示控制文件过旧等问题,所以备份需要经过详细高可用的设计,才能在恢复过程中降低风险。
推荐阅读:
Oracle基础教程之通过RMAN复制数据库
RMAN备份策略制定参考内容
RMAN备份学习笔记
Oracle数据库备份加密 RMAN加密
一、环境说明
操作系统版本: Oracle Enterprise linux 5.8 x64
1. 源数据库服务器
Oracle版本: Oracle 10g RAC 10.2.0.5 64位
Oracle_SID: orcl
2. 目标数据库服务器
Oracle版本 : Oracle 10g 10.2.0.5 64位
Oracle_SID : orcl
只安装了oracle软件,监听,没有dbca操作
二、源DB服务器
1. 源服务器环境说明
源服务器通过执行RAC RMAN备份。需要执行异机恢复操作。
2. 打包或拷贝rman备份目录
$ cd /u01
$ tar czvf rman_bak.tar.gz rman_bak/
三、目的服务器上做RMAN恢复准备
1. 拷贝RMAN备份的数据
# cd /u01/rman_bak/data/
# ll
-rw-r----- 1 oracle oinstall 1080751616 07-18 16:58 archlog.ORCL.level.0.0rof2j8q_1_1_20130718
-rw-r----- 1 oracle oinstall 1018279424 07-18 16:58 archlog.ORCL.level.0.0sof2j8n_1_1_20130718
-rw-r----- 1 oracle oinstall 58086912 07-18 16:58 archlog.ORCL.level.0.0tof2j9l_1_1_20130718
-rw-r----- 1 oracle oinstall 493084672 07-18 16:58 data.ORCL.level.0.0vof2j9v_1_1_20130718
-rw-r----- 1 oracle oinstall 409280512 07-18 16:58 data.ORCL.level.0.10of2j9s_1_1_20130718
-rw-r----- 1 oracle oinstall 15466496 07-18 16:58 data.ORCL.level.0.11of2jae_1_1_20130718
-rw-r----- 1 oracle oinstall 98304 07-18 16:58 spfile_12of2jah_1_1_20130718
#
2. 创建规档日志目录
su - oracle
mkdir -p /u01/archivelog
3. 创建数据库基本目录
说明: 由于rman备份的信息都是记录在controlfile中,所以目录结构应该与原数据库的一致。
mkdir -p /u01/app/oracle/admin/orcl/{adump,bdump,cdump,ddump,udump}
mkdir -p /u01/app/oracle/oradata/orcl
mkdir -p /u01/app/oracle/flash_recovery_area/ORCL
三、目标服务器上恢复数据
说明: 在目标服务器上创建好参数文件中定义的目录,一一在目标服务器创建完毕。
1. 启动到nomount状态
# su - oracle
$ echo 'db_name=orcl' > $ORACLE_HOME/dbs/initorcl.ora
$ export ORACLE_SID=orcl
$ rman target /
RMAN> startup nomount;
2. 通过恢复spfile文件恢复pfile文件
RMAN> restore spfile to pfile '/u01/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora' from '/u01/rman_bak/data/spfile_12of2jah_1_1_20130718';
Starting restore at 19-7? -13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: autobackup found: /u01/rman_bak/data/spfile_12of2jah_1_1_20130718
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 19-7? -13
RMAN> quit
3. 编辑pfile文件
# 修改pfile使用之适合单实例文件系统数据库
$ vi /u01/app/oracle/product/10.2.0/db_1/dbs/initorcl.ora
#注释掉RAC集群的配置参数,并修改部分单实例参数。
#orcl2.__db_cache_size=822083584
#orcl1.__db_cache_size=771751936
#orcl2.__java_pool_size=16777216
#orcl1.__java_pool_size=16777216
#orcl2.__large_pool_size=16777216
#orcl1.__large_pool_size=16777216
#orcl2.__shared_pool_size=352321536
#orcl1.__shared_pool_size=402653184
#orcl2.__streams_pool_size=0
#orcl1.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.background_dump_dest='/u01/app/oracle/admin/orcl/bdump'
#*.cluster_database_instances=2
#*.cluster_database=true
*.compatible='10.2.0.5.0'
*.control_file_record_keep_time=40
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/orcl/cdump'
*.db_block_size=8192
#*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=21474836480
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
#orcl2.instance_number=2
#orcl1.instance_number=1
*.job_queue_processes=10
#*.log_archive_dest_1='LOCATION=+RECOVERY'
*.log_archive_dest_1='LOCATION=/u01/archivelog'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=402653184
*.processes=200
#*.remote_listener='LISTENERS_ORCL'
*.remote_login_passwordfile='exclusive'
*.sessions=225
*.sga_target=1210056704
#orcl2.thread=2
#orcl1.thread=1
*.undo_management='AUTO'
#orcl2.undo_tablespace='UNDOTBS2'
#orcl1.undo_tablespace='UNDOTBS1'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/orcl/udump'
4. 通过修改的pfile重新创建spfile文件
$ sqlplus /nolog
SQL> conn / as sysdba;
SQL> shutdown immediate;
SQL> create spfile from pfile;
# 重新通spfile参数启动
SQL> startup nomount;
SQL> quit
5. 恢复控制文件
说明1: 通过RMAN自动备份的参数与控制文件进行恢复,这个是标准恢复方式,在恢复过程中控制文件通常是比较新的。
说明2: 另一方式是没有自动备份的情况下,通过备份集中的控制文件进行恢复,最后的一个备份集中包含控制文件。
(1) 通过指定备份集恢复控制文件
$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on ?l? 7? 19 12:58:26 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: orcl (not mounted)
RMAN> restore controlfile from '/u01/rman_bak/data/data.ORCL.level.0.11of2jae_1_1_20130718';
Starting restore at 19-7? -13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=211 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output filename=/u01/app/oracle/oradata/orcl/control01.ctl
output filename=/u01/app/oracle/oradata/orcl/control02.ctl
output filename=/u01/app/oracle/oradata/orcl/control03.ctl
Finished restore at 19-7? -13
(2) mount数据库
RMAN>
RMAN> mount database;
database mounted
released channel: ORA_DISK_1
RMAN> quit
6. 将备份集注册进控制文件里
RMAN> catalog start with '/u01/rman_bak/data/';
searching for all files that match the pattern /u01/rman_bak/data/
List of Files Unknown to the Database
=====================================
File Name: /u01/rman_bak/data/archlog.ORCL.level.0.0rof2j8q_1_1_20130718
File Name: /u01/rman_bak/data/data.ORCL.level.0.0vof2j9v_1_1_20130718
File Name: /u01/rman_bak/data/archlog.ORCL.level.0.0sof2j8n_1_1_20130718
File Name: /u01/rman_bak/data/spfile_12of2jah_1_1_20130718
File Name: /u01/rman_bak/data/data.ORCL.level.0.11of2jae_1_1_20130718
File Name: /u01/rman_bak/data/data.ORCL.level.0.10of2j9s_1_1_20130718
File Name: /u01/rman_bak/data/archlog.ORCL.level.0.0tof2j9l_1_1_20130718
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/rman_bak/data/archlog.ORCL.level.0.0rof2j8q_1_1_20130718
File Name: /u01/rman_bak/data/data.ORCL.level.0.0vof2j9v_1_1_20130718
File Name: /u01/rman_bak/data/archlog.ORCL.level.0.0sof2j8n_1_1_20130718
File Name: /u01/rman_bak/data/spfile_12of2jah_1_1_20130718
File Name: /u01/rman_bak/data/data.ORCL.level.0.11of2jae_1_1_20130718
File Name: /u01/rman_bak/data/data.ORCL.level.0.10of2j9s_1_1_20130718
File Name: /u01/rman_bak/data/archlog.ORCL.level.0.0tof2j9l_1_1_20130718
RMAN> quit