ITPub博客

首页 > 数据库 > Oracle > 【数据迁移1】Oracle 10gR2 rman异机恢复实验(FS->RAW)(1)

【数据迁移1】Oracle 10gR2 rman异机恢复实验(FS->RAW)(1)

原创 Oracle 作者:xunzhaoxz 时间:2011-07-23 14:04:30 0 删除 编辑

【数据迁移1】Oracle 10gR2 rman异机恢复实验(FS->RAW)(1)

转载请注明原文:http://xunzhaoxz.itpub.net/post/40016/521239

PDF版详细恢复步骤(截图)

【数据迁移2】Oracle 10gR2 rman异机恢复实验(FS-FS)(截图)

环境说明

Oracle源主机

Oracle目标主机

主机平台

RHEL5.4 2.6.18-164.el5

RHEL5.4 2.6.18-164.el5

主机名

olddbser

newdbser

DB name

oradb

oradb

实例名

oradb

oradb

Oracle版本

10.2.0.1

10.2.0.1>10.2.0.4

Oracle数据文件存储

Filesystem

LVM RAW LV

单机或RAC

单机

单机

[@more@]

二、 前期准备

2.1. 信息采集

sys用户登录源库oradb,执行以下命令收集相关信息。

2.1.1. 查看参数文件

SQL> show parameter spfile;

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

spfile string /oracle/product/10.2/db_1/dbs/

spfileoradb.ora

SQL>

2.1.2. cat 参数文件

[oracle@Oradb1 ~]$ cat /oracle/product/10.2/db_1/dbs/spfileoradb.ora

[1][1]??oradb.__db_cache_size=75497472

oradb.__java_pool_size=4194304

oradb.__large_pool_size=4194304

oradb.__shared_pool_size=75497472

oradb.__streams_pool_size=0

*.audit_file_dest='/oracle/admin/oradb/adump'

*.background_dump_dest='/oracle/admin/oradb/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/oracle/oradata/ORADB/controlfile/o1_mf_6ccmcxjq_.ctl'

*.core_dump_dest='/oracle/admin/oradb/cdump'

*.db_block_size=8192

*.db_create_file_dest='/oracle/oradata'

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='oradb'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=oradbXDB)'

*.job_queue_processes=10

*.log_archive_dest_1='LOCATION=/oracle/oradata/oradb/archivelog'

*.log_archive_format='%t_%s_%r.dbf'

*.nls_language='SIMPLIFIED CHINESE'

*.nls_territory='CHINA'

*.open_cursors=300

*.pga_aggregate_target=16777216

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=167772160

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/oracle/admin/oradb/udump'

[oracle@Oradb1 ~]$

2.1.3. 查看redo log

SQL> set linesize 250

SQL> col member format a60

SQL> select group#,status,type, member from v$logfile;

GROUP# STATUS TYPE MEMBER

---------- ------- ------- ------------------------------------------------------------

3 ONLINE /oracle/oradata/ORADB/onlinelog/o1_mf_3_6ccmd4s8_.log

2 ONLINE /oracle/oradata/ORADB/onlinelog/o1_mf_2_6ccmd34r_.log

1 ONLINE /oracle/oradata/ORADB/onlinelog/o1_mf_1_6ccmd1ns_.log

SQL>

2.1.4. 查看数据文件

SQL> col name format a65

SQL> select file#,name,bytes/1024/1024 MB from v$datafile;

2.1.5. 查看控制文件

SQL> col name format a66

SQL> select name from v$controlfile;

NAME

------------------------------------------------------------------

/oracle/oradata/ORADB/controlfile/o1_mf_6ccmcxjq_.ctl

SQL>

2.1.6. strings控制文件

[oracle@Oradb1 ~]$ strings /oracle/oradata/ORADB/controlfile/o1_mf_6ccmcxjq_.ctl

}|{z

ORADB

+ORADB

+ORADB

oradb

oradb

/oracle/oradata/ORADB/onlinelog/o1_mf_3_6ccmd4s8_.log

/oracle/oradata/ORADB/onlinelog/o1_mf_2_6ccmd34r_.log

/oracle/oradata/ORADB/onlinelog/o1_mf_1_6ccmd1ns_.log

/oracle/oradata/ORADB/datafile/o1_mf_users_6ccmb0x6_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_sysaux_6ccmb0pf_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_undotbs1_6ccmb0w4_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_system_6ccmb0oy_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_temp_6ccmdhv3_.tmp

/oracle/oradata/autobackup/snapcf_rman.f

/oracle/oradata/ORADB/onlinelog/o1_mf_3_6ccmd4s8_.log

/oracle/oradata/ORADB/onlinelog/o1_mf_2_6ccmd34r_.log

/oracle/oradata/ORADB/onlinelog/o1_mf_1_6ccmd1ns_.log

/oracle/oradata/ORADB/datafile/o1_mf_users_6ccmb0x6_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_sysaux_6ccmb0pf_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_undotbs1_6ccmb0w4_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_system_6ccmb0oy_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_temp_6ccmdhv3_.tmp

/oracle/oradata/autobackup/snapcf_rman.f

SYSTEM

UNDOTBS1

SYSAUX

USERS

TEMP

SYSTEM

UNDOTBS1

SYSAUX

USERS

TEMP

CONTROLFILE AUTOBACKUP

CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE

DISK TO '/oracle/oradata/autobackup/oradb-cf-%F.dbf'

CHANNEL

DEVICE TYPE DISK FORMAT '/oracle/oradata/backupset/oradb-bs-%T-%U.dbf'

RETENTION POLICY

TO RECOVERY WINDOW OF 2 DAYS

CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE

DISK TO '/oracle/oradata/autobackup/oradb-cf-%F.dbf'

CHANNEL

DEVICE TYPE DISK FORMAT '/oracle/oradata/backupset/oradb-bs-%T-%U.dbf'

RETENTION POLICY

TO RECOVERY WINDOW OF 2 DAYS

oracle/oradata/oradb/archivelog/1_2_732323841.dbf

oracle/oradata/oradb/archivelog/1_3_732323841.dbf

oracle/oradata/oradb/archivelog/1_4_732323841.dbf

oracle/oradata/oradb/archivelog/1_5_732323841.dbf

oracle/oradata/oradb/archivelog/1_6_732323841.dbf

oracle/oradata/oradb/archivelog/1_7_732323841.dbf

……………………………………

……………………………………

2.1.7. 查看当前归档模式、归档路径

SQL> set linesize 120

SQL> col error format a10

SQL> col dest_name format a20

SQL> col destination format a50

SQL> col status format a14

SQL> select dest_name,destination,status,error from v$archive_dest;

2.1.8. 查看当前rman配置策略

RMAN> show all;

RMAN configuration parameters are:

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1000 DAYS;

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oracle/oradata/autobackup/oradb-cf-%F.dbf';

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/oracle/oradata/backupset/oradb-bs-%T-%U.dbf';

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/product/10.2/db_1/dbs/snapcf_oradb.f'; # default

RMAN>

2.2. 数据备份

2.2.1. 手工创建pfile以备用

SQL> create pfile='/oracle/oradb-pfile-201011111134.ora' from spfile;

File created.

SQL>

[oracle@Oradb1 ~]$ ls -l /oracle/oradb-pfile*

-rw-r--r-- 1 oracle oinstall 990 Nov 11 11:28 /oracle/oradb-pfile-201011111134.ora

[oracle@Oradb1 ~]$

2.2.2. rman启用控制文件自动备份

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

old RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP OFF;

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

RMAN>

2.2.3. 切换logfile

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

2.2.4. 备份数据库

备份生成的备份集为 /oracle/ oradb-20101114-1jlt0ptg_1_1.rman,同时控制文件和参数文件也自动备份为/oracle/oradata/autobackup/oradb-cf-c-2485588605-20101114-00.dbf

RMAN> backup database format '/oracle/oradb-%T-%U.rman';

Starting backup at 2010-11-14 20:25:19

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=136 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/oracle/oradata/ORADB/datafile/o1_mf_system_6ccmb0oy_.dbf

input datafile fno=00003 name=/oracle/oradata/ORADB/datafile/o1_mf_sysaux_6ccmb0pf_.dbf

input datafile fno=00002 name=/oracle/oradata/ORADB/datafile/o1_mf_undotbs1_6ccmb0w4_.dbf

input datafile fno=00004 name=/oracle/oradata/ORADB/datafile/o1_mf_users_6ccmb0x6_.dbf

channel ORA_DISK_1: starting piece 1 at 2010-11-14 20:25:20

channel ORA_DISK_1: finished piece 1 at 2010-11-14 20:26:25

piece handle=/oracle/oradb-20101114-1jlt0ptg_1_1.rman tag=TAG20101114T202520 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05

Finished backup at 2010-11-14 20:26:26

Starting Control File and SPFILE Autobackup at 2010-11-14 20:26:26

piece handle=/oracle/oradata/autobackup/oradb-cf-c-2485588605-20101114-00.dbf comment=NONE

Finished Control File and SPFILE Autobackup at 2010-11-14 20:26:27

RMAN>

2.2.5. 备份归档日志并删除

备份归档日志生成的备份集为/oracle/oradb-20101114-1jlt0ptg_1_1.rman,同时控制文件和参数文件也自动备份到/oracle/oradata/autobackup/oradb-cf-c-2485588605-20101114-01.dbf

注意:这里自动备份得到的控制文件是最新的,本环境rman采用的是nocatalog模式,因此该控制文件备份集中记录了归档日志文件的相关信息,进行数据恢复需要用到。

RMAN> backup archivelog all delete input format '/oracle/oradb-archlogall-%T-%U.rman';

Starting backup at 2010-11-14 20:28:04

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log backupset

channel ORA_DISK_1: specifying archive log(s) in backup set

input archive log thread=1 sequence=21 recid=20 stamp=734574755

input archive log thread=1 sequence=22 recid=22 stamp=734579607

input archive log thread=1 sequence=23 recid=21 stamp=734579603

input archive log thread=1 sequence=24 recid=23 stamp=734579611

input archive log thread=1 sequence=25 recid=24 stamp=734579612

input archive log thread=1 sequence=26 recid=25 stamp=734579622

input archive log thread=1 sequence=27 recid=26 stamp=735064060

input archive log thread=1 sequence=28 recid=27 stamp=735077844

input archive log thread=1 sequence=29 recid=28 stamp=735077845

input archive log thread=1 sequence=30 recid=30 stamp=735077854

input archive log thread=1 sequence=31 recid=29 stamp=735077854

input archive log thread=1 sequence=32 recid=31 stamp=735077873

input archive log thread=1 sequence=33 recid=32 stamp=735077875

input archive log thread=1 sequence=34 recid=33 stamp=735077877

input archive log thread=1 sequence=35 recid=34 stamp=735077888

input archive log thread=1 sequence=36 recid=35 stamp=735078484

channel ORA_DISK_1: starting piece 1 at 2010-11-14 20:28:07

channel ORA_DISK_1: finished piece 1 at 2010-11-14 20:28:14

piece handle=/oracle/oradb-archlogall-20101114-1llt0q2m_1_1.rman tag=TAG20101114T202804 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08

channel ORA_DISK_1: deleting archive log(s)

archive log filename=/oracle/oradata/oradb/archivelog/1_21_732323841.dbf recid=20 stamp=734574755

archive log filename=/oracle/oradata/oradb/archivelog/1_22_732323841.dbf recid=22 stamp=734579607

archive log filename=/oracle/oradata/oradb/archivelog/1_23_732323841.dbf recid=21 stamp=734579603

archive log filename=/oracle/oradata/oradb/archivelog/1_24_732323841.dbf recid=23 stamp=734579611

archive log filename=/oracle/oradata/oradb/archivelog/1_25_732323841.dbf recid=24 stamp=734579612

archive log filename=/oracle/oradata/oradb/archivelog/1_26_732323841.dbf recid=25 stamp=734579622

archive log filename=/oracle/oradata/oradb/archivelog/1_27_732323841.dbf recid=26 stamp=735064060

archive log filename=/oracle/oradata/oradb/archivelog/1_28_732323841.dbf recid=27 stamp=735077844

archive log filename=/oracle/oradata/oradb/archivelog/1_29_732323841.dbf recid=28 stamp=735077845

archive log filename=/oracle/oradata/oradb/archivelog/1_30_732323841.dbf recid=30 stamp=735077854

archive log filename=/oracle/oradata/oradb/archivelog/1_31_732323841.dbf recid=29 stamp=735077854

archive log filename=/oracle/oradata/oradb/archivelog/1_32_732323841.dbf recid=31 stamp=735077873

archive log filename=/oracle/oradata/oradb/archivelog/1_33_732323841.dbf recid=32 stamp=735077875

archive log filename=/oracle/oradata/oradb/archivelog/1_34_732323841.dbf recid=33 stamp=735077877

archive log filename=/oracle/oradata/oradb/archivelog/1_35_732323841.dbf recid=34 stamp=735077888

archive log filename=/oracle/oradata/oradb/archivelog/1_36_732323841.dbf recid=35 stamp=735078484

Finished backup at 2010-11-14 20:28:15

Starting Control File and SPFILE Autobackup at 2010-11-14 20:28:15

piece handle=/oracle/oradata/autobackup/oradb-cf-c-2485588605-20101114-01.dbf comment=NONE

Finished Control File and SPFILE Autobackup at 2010-11-14 20:28:19

RMAN>

三、 异机恢复

3.1. 创建组、用户

3.1.1. groupadduseradd

newdbser上创建用户组、用户如下:

#groupadd -g 501 oinstall

#groupadd -g 502 dba

#useradd -u 501 -g oinstall -G dba oracle

3.1.2. 编辑用户配置文件

export EDITOR=vi

export ORACLE_SID=oradb

export ORACLE_BASE=/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2/db_1

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export NLS_LANG="American_america.zhs16gbk"

export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';

export PATH =$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin

3.2. 安装oracle补丁

Oracle 10.2.0.1不支持lvm lv裸设备作为datafile,因此如果直接将备份集恢复到10.2.0.1的话,将出现ORA-27094的错误,错误日志如下:

##########以下为10.2.0.1环境下将datafile恢复到裸设备下的报错日志###############

RMAN> @/oracle/restore_raw.rman

RMAN> run

2> {

3> SET NEWNAME FOR DATAFILE

'/oracle/oradata/ORADB/datafile/o1_mf_users_6ccmb0x6_.dbf'

TO '/oracle/oradata/oradb/user_128m';

4> SET NEWNAME FOR DATAFILE

'/oracle/oradata/ORADB/datafile/o1_mf_sysaux_6ccmb0pf_.dbf'

TO '/oracle/oradata/oradb/sysaux_512m';

5> SET NEWNAME FOR DATAFILE

'/oracle/oradata/ORADB/datafile/o1_mf_undotbs1_6ccmb0w4_.dbf'

TO '/oracle/oradata/oradb/undo01_512m';

6> SET NEWNAME FOR DATAFILE

'/oracle/oradata/ORADB/datafile/o1_mf_system_6ccmb0oy_.dbf'

TO '/oracle/oradata/oradb/system_1g';

7> set until scn 556840;

8> restore database;

9> switch datafile all;

10> recover database;

11> }

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET until clause

Starting restore at 2010-11-09 20:13:58

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /oracle/oradata/oradb/system_1g

restoring datafile 00002 to /oracle/oradata/oradb/undo01_512m

restoring datafile 00003 to /oracle/oradata/oradb/sysaux_512m

restoring datafile 00004 to /oracle/oradata/oradb/user_128m

channel ORA_DISK_1: reading from backup piece /oracle/oradb-20101109-1flshds1_1_1.rman

ORA-19870: error reading backup piece /oracle/oradb-20101109-1flshds1_1_1.rman

ORA-19504: failed to create file "/oracle/oradata/oradb/system_1g"

ORA-27094: raw volume used can damage partition table

Additional information: -2

Additional information: 1073741824

##########以上为10.2.0.1环境下将datafile恢复到裸设备下的报错日志###############

关于ORA-27094,详见《Linux x86平台下Oracle 10.2.0.1 ORA-27094》一文。

3.2.1. 停止相关进程

$ emctl stop dbconsole

$ isqlplusctl stop

$ lsnrctl stop

shutdown数据库实例

如果使用ASM,需要将ASMshutdown

具体可以查看补丁包中的patch_note.htm文档。

3.2.2. 备份相关文件

Oracle recommends that you create a backup of the Oracle Inventory, Oracle 10g home and Oracle 10g Database before you install the patch set.

3.2.3. 设置DISPLAY参数

需要设置DISPLAY才能使用图形界面方式安装;若采用静默安装,则不需要设置DISPLAY

3.2.4. 执行runInstaller安装

% cd patchset_directory/Disk1
% ./runInstaller
注意:在选择安装目录时,需要指定当初安装10.2.0.1的目录即$ORACLE_HOME,否则将安装失败。

3.3. 创建空实例

对于类Unix平台,创建oracle空实例实际上就是创建oracle相关的一些目录。

oracle用户执行以下命令创建相关目录:

$mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID

$mkdir $ORACLE_BASE/admin/$ORACLE_SID

$cd $ORACLE_BASE/admin/$ORACLE_SID

$mkdir pfile bdump udump cdump

3.4. 重建密码文件

$orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle

3.5. 设置DBID

[oracle@Ora_tar mapper]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Mon Nov 15 14:51:02 2010

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database (not started)

RMAN> set DBID 2485588605;

executing command: SET DBID

RMAN>

3.6. 将数据库启动到nomount状态

这里会报错提示找不到相关的spfilepfileinitSID.ora等参数文件。

RMAN> startup nomount;

startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/oracle/product/10.2/db_1/dbs/initoradb.ora'

starting Oracle instance without parameter file for retrival of spfile

Oracle instance started

Total System Global Area 159383552 bytes

Fixed Size 1266320 bytes

Variable Size 58723696 bytes

Database Buffers 92274688 bytes

Redo Buffers 7118848 bytes

RMAN>

3.7. 恢复参数文件

RMAN> restore spfile to pfile '/oracle/oradata/initoradb.ora' from '/oracle/oradb-cf-c-2485588605-20101114-01.dbf';

Starting restore at 2010-11-15 14:53:55

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: /oracle/oradb-cf-c-2485588605-20101114-01.dbf

channel ORA_DISK_1: SPFILE restore from autobackup complete

Finished restore at 2010-11-15 14:53:58

RMAN>

3.8. 用恢复的pfile将数据库启动到nomount状态

使用上一步恢复的参数文件/oracle/oradata/initoradb.ora将数据库启动到nomount状态。

RMAN> startup force nomount pfile='/oracle/oradata/initoradb.ora';

Oracle instance started

Total System Global Area 167772160 bytes

Fixed Size 1266368 bytes

Variable Size 79695168 bytes

Database Buffers 79691776 bytes

Redo Buffers 7118848 bytes

RMAN>

3.9. 恢复控制文件

RMAN> restore controlfile from '/oracle/oradb-cf-c-2485588605-20101114-01.dbf';

注意:这里用于恢复的控制文件源为上一步备份数据库及归档日志两步中后一步生成的文件集。

Starting restore at 2010-11-15 14:54:34

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

output filename=/oracle/oradata/ORADB/controlfile/o1_mf_6g1p9dt0_.ctl

Finished restore at 2010-11-15 14:54:37

RMAN>

3.10. mount数据库

RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1

RMAN>

接:【数据迁移1】Oracle 10gR2 rman异机恢复实验(FS->RAW)(2

http://xunzhaoxz.itpub.net/post/40016/522834

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22085031/viewspace-1052927/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-11-09

  • 博文量
    27
  • 访问量
    698539