Oracle 单实例 迁移到 RAC 实例 -- 使用RMAN 异机恢复

Oracle 官网有关单实例迁移到RAC的一个步骤说明:

How to Convert 10g Single-Instance database to 10g RAC using Manual Conversion procedure [ID 747457.1]

http://blog.csdn.net/tianlesoftware/archive/2010/12/09/6065903.aspx

RMAN 备份异机恢复 并创建新DBID

http://blog.csdn.net/tianlesoftware/archive/2011/03/11/6240983.aspx

. 大致操作步骤如下:

1. 安装Clusterware ASM 实例

2. 备份源库,并将备份集copyrac 节点上

3. RAC 上还原并修改初始化参数文件,还原控制文件和数据文件

4. 增加undo 表空间和redo log 线程组,创建密钥文件

5. 配置RAC监听

6. 将数据库等资源添加到CRS

注意: 迁移的2db版本版本要一致。包括小版本。 比如10.2.0.4.0.

我这个测试的时候是从10.2.0.1.0 迁移到10.2.0.4.0. 结果在open resetlogs的时候报错了,必须要先升级后,才能打开。

Redhat 5.4 Orcle RAC 数据库 10.2.0.1升级到 10.2.0.4

http://blog.csdn.net/tianlesoftware/archive/2010/09/16/5888069.aspx

. 具体操作步骤

2.1 安装Clusterware ASM 实例

这个参考Blog

Redhat 5.4 Oracle 10g RAC Openfiler+Multipath + RAW+ ASM 安装文档

http://blog.csdn.net/tianlesoftware/archive/2010/12/01/6048792.aspx

安装之后的进程如下:

[oracle@rac1 u01]$ sh crs_stat.sh

Name Target State Host

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

ora.rac1.ASM1.asm ONLINE ONLINE rac1

ora.rac1.gsd ONLINE ONLINE rac1

ora.rac1.ons ONLINE ONLINE rac1

ora.rac1.vip ONLINE ONLINE rac1

ora.rac2.ASM2.asm ONLINE ONLINE rac2

ora.rac2.gsd ONLINE ONLINE rac2

ora.rac2.ons ONLINE ONLINE rac2

ora.rac2.vip ONLINE ONLINE rac2

2.2 在源库用RMAN 备份,并将备份文件copyrac

相关备份脚本,参考Blog

Linux 平台下 RMAN 全备 增量备份 shell 脚本

http://blog.csdn.net/tianlesoftware/archive/2010/07/16/5740630.aspx

Nocatalog 下的RMAN 增量备份 shell脚本

http://blog.csdn.net/tianlesoftware/archive/2011/01/26/6164931.aspx

源库实例名:anqing,为了确认迁移成功,我们现在源库上创建一个表dave,并插入一条记录。

SQL> create table dave(id number,hometown varchar2(100));

Table created.

SQL> insert into dave values(1,'安徽省安庆市怀宁县');

1 row created.

SQL> commit;

Commit complete.

nocatalog 方式进行0级备份。

备份之后的信息如下:

RMAN> list backup summary;

using target database control file instead of recovery catalog

List of Backups

===============

Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

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

1 B 0 A DISK 23-MAY-12 1 1 NO ANQING_LEV0

2 B 0 A DISK 23-MAY-12 1 1 NO ANQING_LEV0

5 B 0 A DISK 23-MAY-12 1 1 NO ANQING_LEV0

6 B 0 A DISK 23-MAY-12 1 1 NO ANQING_LEV0

7 B A A DISK 23-MAY-12 1 1 NO ARC_BAK

8 B A A DISK 23-MAY-12 1 1 NO ARC_BAK

9 B F A DISK 23-MAY-12 1 1 NO BAK_CTLFILE

10 B F A DISK 23-MAY-12 1 1 NO SPFILE

注:我虚拟机上的系统时间没改,所以这里显示的时间是2012523日。

将备份文件SCP RAC 服务器:

[oracle@singledb backup]$ scp * 192.168.2.42:/u01/backup

[email protected]'s password:

anqing_lev0_01nbo3f3_1_1_20120523 100% 350MB 1.8MB/s 03:14

anqing_lev0_02nbo3f3_1_1_20120523 100% 142MB 2.7MB/s 00:53

anqing_lev0_03nbo3f3_1_1_20120523 100% 21MB 3.1MB/s 00:07

anqing_lev0_04nbo3f4_1_1_20120523 100% 376KB 376.0KB/s 00:00

anqing_spfile_0anbo3jl_1_1_20120523 100% 96KB 96.0KB/s 00:00

arch_07nbo3je_1_1_20120523 100% 28MB 3.1MB/s 00:09

arch_08nbo3je_1_1_20120523 100% 2560 2.5KB/s 00:00

ctl_file_09nbo3jk_1_1_20120523 100% 6944KB 3.4MB/s 00:02

2.3 还原并修改初始化文件

2.3.1 还原spfile pfile

[oracle@rac1 ~]$ export ORACLE_SID=anqing1

[oracle@rac1 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Wed May 18 22:54:27 2011

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

connected to target database (not started)

RMAN> startup nomount

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

LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initanqing1.ora'

starting Oracle instance without parameter file for retrival of spfile

Oracle instance started

Total System Global Area 159383552 bytes

Fixed Size 1266344 bytes

Variable Size 58723672 bytes

Database Buffers 96468992 bytes

Redo Buffers 2924544 bytes

RMAN> restore spfile to pfile '/u01/app/oracle/product/10.2.0/db_1/dbs/initanqing1.ora'

2> from '/u01/backup/anqing_spfile_0anbo3jl_1_1_20120523';

Starting restore at 18-MAY-11

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=33 devtype=DISK

channel ORA_DISK_1: autobackup found: /u01/backup/anqing_spfile_0anbo3jl_1_1_20120523

channel ORA_DISK_1: SPFILE restore from autobackup complete

Finished restore at 18-MAY-11

RMAN>

看一下我们刚才恢复的参数文件:

[oracle@rac1 backup]$ cd /u01/app/oracle/product/10.2.0/db_1/dbs/

[oracle@rac1 dbs]$

[oracle@rac1 dbs]$ ls

ab_+ASM1.dat hc_anqing.dat hc_dave1.dat initanqing.ora init.ora orapw+ASM1

ab_+ASM2.dat hc_+ASM1.dat hc_rac1.dat init+ASM1.ora init.ora.4122011215823 snapcf_dave1.f

core_10447 hc_+ASM2.dat hc_rac2.dat initdw.ora initrac1.ora spfilerac1.ora

[oracle@rac1 dbs]$ cat initanqing.ora

anqing.__db_cache_size=96468992

anqing.__java_pool_size=4194304

anqing.__large_pool_size=4194304

anqing.__shared_pool_size=58720256

anqing.__streams_pool_size=0

*.audit_file_dest='/u01/app/oracle/admin/anqing/adump'

*.background_dump_dest='/u01/app/oracle/admin/anqing/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/u01/app/oracle/oradata/anqing/control01.ctl','/u01/app/oracle/oradata/anqing/control02.ctl','/u01/app/oracle/oradata/anqing/control03.ctl'

*.core_dump_dest='/u01/app/oracle/admin/anqing/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='anqing'

*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=2147483648

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

*.job_queue_processes=10

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

*.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='/u01/app/oracle/admin/anqing/udump'

这里面都是单实例的参数,我们需要把这个改成RAC的参数。

2.3.2 查看ASM 实例的相关目录信息

[oracle@rac1 ~]$ export ORACLE_SID=+ASM1

[oracle@rac1 ~]$ sqlplus / as sysdba;

SQL*Plus: Release 10.2.0.4.0 - Production on Wed May 18 23:09:32 2011

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production

With the Partitioning, Real Application Clusters, OLAP, Data Mining

and Real Application Testing options

SYS@+ASM1(rac1)> col state format a10

SYS@+ASM1(rac1)> col name format a15

SYS@+ASM1(rac1)> col failgroup format a20

SYS@+ASM1(rac1)> set line 200

SYS@+ASM1(rac1)> select state,redundancy,total_mb,free_mb,name,failgroup from v$asm_disk;

STATE REDUNDA TOTAL_MB FREE_MB NAME FAILGROUP

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

NORMAL UNKNOWN 11993 10088 DATA DATA

NORMAL UNKNOWN 7993 38 FRA_0000 FRA_0000

SYS@+ASM1(rac1)> select group_number,name,state,type,total_mb,free_mb,unbalanced from v$asm_diskgroup;

GROUP_NUMBER NAME STATE TYPE TOTAL_MB FREE_MB U

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

1 DATA MOUNTED EXTERN 11993 10088 N

2 FRA MOUNTED EXTERN 7993 38 N

使用ASMCMD命令:

[oracle@rac1 ~]$ export ORACLE_SID=+ASM1

[oracle@rac1 ~]$ asmcmd

ASMCMD> help

asmcmd [-p] [command]

The environment variables ORACLE_HOME and ORACLE_SID determine the

instance to which the program connects, and ASMCMD establishes a

bequeath connection to it, in the same manner as a SQLPLUS / AS

SYSDBA. The user must be a member of the SYSDBA group.

Specifying the -p option allows the current directory to be displayed

in the command prompt, like so:

ASMCMD [+DATAFILE/ORCL/CONTROLFILE] >

[command] specifies one of the following commands, along with its

parameters.

Type "help [command]" to get help on a specific ASMCMD command.

commands:

--------

cd

du

find

help

ls

lsct

lsdg

mkalias

mkdir

pwd

rm

rmalias

ASMCMD> ls

DATA/

FRA/

-- 这个是我们的两个磁盘组

ASMCMD> cd DATA

ASMCMD> ls

DAVE/

DB_UNKNOWN/

RAC/

-- 每个实例都对应一个目录,如果我们在创建参数的时候,没有这个目录,可以手工的先创建一下这个目录

ASMCMD> cd ..

ASMCMD> ls

DATA/

FRA/

ASMCMD> cd FRA

ASMCMD> ls

DAVE/

RAC/

ASMCMD>

2.3.3 修改初始话参数

注意事项:

1RMAN 异机恢复的db_name 必须和备份的一致,如果说想改成其他名称,可以等还原之后,在用nid 命令修改。

2)控制文件需要指定到共享设备上

3)检查audit_file_destbackground_dump_dest core_dump_destlog_archive_dest_1user_dump_dest等参数的位置。 如果2个节点和共享位置没有对应的目录,先把目录建好。

[oracle@rac1 admin]$ pwd

/u01/app/oracle/admin

[oracle@rac1 admin]$ mkdir anqing

[oracle@rac1 admin]$ ls

anqing +ASM rac

[oracle@rac1 admin]$ cd anqing

[oracle@rac1 anqing]$ mkdir adump

[oracle@rac1 anqing]$ mkdir bdump

[oracle@rac1 anqing]$ mkdir cdump

[oracle@rac1 anqing]$ mkdir dpdump

[oracle@rac1 anqing]$ mkdir hdump

[oracle@rac1 anqing]$ mkdir pfile

[oracle@rac1 anqing]$ mkdir udump

[oracle@rac1 anqing]$ ll

total 28

drwxr-xr-x 2 oracle oinstall 4096 May 18 23:40 adump

drwxr-xr-x 2 oracle oinstall 4096 May 18 23:40 bdump

drwxr-xr-x 2 oracle oinstall 4096 May 18 23:40 cdump

drwxr-xr-x 2 oracle oinstall 4096 May 18 23:41 dpdump

drwxr-xr-x 2 oracle oinstall 4096 May 18 23:41 hdump

drwxr-xr-x 2 oracle oinstall 4096 May 18 23:41 pfile

drwxr-xr-x 2 oracle oinstall 4096 May 18 23:41 udump

之前一个RAC 环境的ASM 目录如下,我们可以参考这个目录来建:

ASMCMD> ls

DATA/

FRA/

ASMCMD> cd DATA

-- 看下DATA目录下的目录层级

ASMCMD> ls

RAC/

ASMCMD> cd RAC

ASMCMD> ls

CONTROLFILE/

DATAFILE/

TEMPFILE/

ONLINELOG/

PARAMETERFILE/

spfilerac.ora

ASMCMD> cd CONTROLFILE

ASMCMD> ls

Current.260.746634201

ASMCMD> cd ..

ASMCMD> cd DATAFILE

ASMCMD> ls

SYSAUX.257.746634087

SYSTEM.256.746634087

UNDOTBS1.258.746634089

UNDOTBS2.264.746634255

USERS.259.746634089

ASMCMD> cd ..

ASMCMD> cd TEMPFILE

ASMCMD> ls

TEMP.263.746634229

ASMCMD> cd ..

ASMCMD> ls

CONTROLFILE/

DATAFILE/

TEMPFILE/

spfilerac.ora

ASMCMD> cd ..

ASMCMD> cd ..

ASMCMD> ls

DATA/

FRA/

ASMCMD> cd FRA

--看下FRA 目录下的层级

ASMCMD> ls

RAC/

ASMCMD> cd RAC

ASMCMD> ls

1_95_746989315.arc

1_96_746989315.arc

CONTROLFILE/

--归档文件因为我指定到这个目录了,所以限制在这里,这里可以在建一个目录,专门存放归档文件

ASMCMD> cd CONTROLFILE

ASMCMD> ls

Current.256.746634203

ASMCMD>

官网文档说明需要添加如下参数:

*.cluster_database = TRUE

*.cluster_database_instances = 2

*.undo_management=AUTO

.undo_tablespace=undotbs (undo tablespace which already exists)

.instance_name=

.instance_number=1

.thread=1

.local_listener=_

.instance_name=

你可能感兴趣的:(Oracle,虚拟机,RedHat,SQL,.net)