1. 程式人生 > >Oracle 單例項 遷移到 RAC 例項 -- 使用RMAN 異機恢復

Oracle 單例項 遷移到 RAC 例項 -- 使用RMAN 異機恢復

Oracle 官網有關單例項遷移到RAC的一個步驟說明:

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

RMAN 備份異機恢復並建立新DBID

. 大致操作步驟如下:

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

. 具體操作步驟

2.1 安裝Clusterware ASM 例項

這個參考Blog

Redhat 5.4 Oracle 10g RAC Openfiler+Multipath + RAW+ ASM

安裝文件

安裝之後的程序如下:

[[email protected] u01]$ sh crs_stat.sh

NameTargetStateHost

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

ora.rac1.ASM1.asmONLINEONLINErac1

ora.rac1.gsdONLINEONLINErac1

ora.rac1.ons ONLINEONLINErac1

ora.rac1.vipONLINEONLINErac1

ora.rac2.ASM2.asmONLINEONLINErac2

ora.rac2.gsdONLINEONLINErac2

ora.rac2.ons ONLINEONLINErac2

ora.rac2.vipONLINEONLINErac2

2.2 在源庫用RMAN 備份,並將備份檔案copyrac

相關備份指令碼,參考Blog

Linux 平臺下 RMAN 全備 增量備份 shell 指令碼

Nocatalog 下的RMAN 增量備份 shell指令碼

源庫例項名: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

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

KeyTY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

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

1B0A DISK23-MAY-1211NOANQING_LEV0

2B0A DISK23-MAY-1211NOANQING_LEV0

5B0A DISK23-MAY-1211 NOANQING_LEV0

6B0A DISK23-MAY-1211NOANQING_LEV0

7BAA DISK23-MAY-1211NOARC_BAK

8BAA DISK23-MAY-1211NOARC_BAK

9BFA DISK23-MAY-1211NOBAK_CTLFILE

10BFA DISK23-MAY-1211NOSPFILE

注:我虛擬機器上的系統時間沒改,所以這裡顯示的時間是2012523日。

將備份檔案SCP RAC 伺服器:

[[email protected] backup]$ scp * 192.168.2.42:/u01/backup

[email protected]'s password:

anqing_lev0_01nbo3f3_1_1_20120523100%350MB1.8MB/s03:14

anqing_lev0_02nbo3f3_1_1_20120523100%142MB2.7MB/s 00:53

anqing_lev0_03nbo3f3_1_1_20120523100%21MB3.1MB/s00:07

anqing_lev0_04nbo3f4_1_1_20120523100%376KB 376.0KB/s00:00

anqing_spfile_0anbo3jl_1_1_20120523100%96KB96.0KB/s00:00

arch_07nbo3je_1_1_20120523100%28MB3.1MB/s00:09

arch_08nbo3je_1_1_20120523100% 25602.5KB/s00:00

ctl_file_09nbo3jk_1_1_20120523100% 6944KB3.4MB/s00:02

2.3 還原並修改初始化檔案

2.3.1 還原spfile pfile

[[email protected] ~]$ export ORACLE_SID=anqing1

[[email protected] ~]$ 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 Area159383552 bytes

Fixed Size1266344 bytes

Variable Size58723672 bytes

Database Buffers96468992 bytes

Redo Buffers2924544 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>

看一下我們剛才恢復的引數檔案:

[[email protected] backup]$ cd /u01/app/oracle/product/10.2.0/db_1/dbs/

[[email protected] dbs]$

[[email protected] dbs]$ ls

ab_+ASM1.dathc_anqing.dathc_dave1.datinitanqing.orainit.oraorapw+ASM1

ab_+ASM2.dathc_+ASM1.dathc_rac1.datinit+ASM1.orainit.ora.4122011215823snapcf_dave1.f

core_10447hc_+ASM2.dathc_rac2.datinitdw.orainitrac1.oraspfilerac1.ora

[[email protected] 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 例項的相關目錄資訊

[[email protected] ~]$ export ORACLE_SID=+ASM1

[[email protected] ~]$ 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

[email protected]+ASM1(rac1)> col state format a10

[email protected]+ASM1(rac1)> col name format a15

[email protected]+ASM1(rac1)> col failgroup format a20

[email protected]+ASM1(rac1)> set line 200

[email protected]+ASM1(rac1)>selectstate,redundancy,total_mb,free_mb,name,failgroup from v$asm_disk;

STATEREDUNDATOTAL_MBFREE_MB NAMEFAILGROUP

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

NORMALUNKNOWN1199310088 DATADATA

NORMALUNKNOWN799338 FRA_0000FRA_0000

[email protected]+ASM1(rac1)> selectgroup_number,name,state,type,total_mb,free_mb,unbalancedfrom v$asm_diskgroup;

GROUP_NUMBER NAMESTATETYPETOTAL_MBFREE_MB U

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

1 DATA MOUNTEDEXTERN1199310088 N

2 FRAMOUNTEDEXTERN799338 N

使用ASMCMD命令:

[[email protected] ~]$ export ORACLE_SID=+ASM1

[[email protected] ~]$ 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個節點和共享位置沒有對應的目錄,先把目錄建好。

[[email protected] admin]$ pwd

/u01/app/oracle/admin

[[email protected] admin]$ mkdir anqing

[[email protected] admin]$ ls

anqing+ASMrac

[[email protected] admin]$ cd anqing

[[email protected] anqing]$ mkdir adump

[[email protected] anqing]$ mkdir bdump

[[email protected] anqing]$ mkdir cdump

[[email protected] anqing]$ mkdir dpdump

[[email protected] anqing]$ mkdir hdump

[[email protected] anqing]$ mkdir pfile

[[email protected] anqing]$ mkdir udump

[[email protected] 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

<SID1>.undo_tablespace=undotbs (undo tablespace which already exists)

<SID1>.instance_name=<SID1>

<SID1>.instance_number=1

<SID1>.thread=1

<SID1>.local_listener=<LISTENERNAME>_<HOSTNAME1>

<SID2>.instance_name=<SID2>

<SID2>.instance_number=2

<SID2>.local_listener=<LISTENERNAME>_<HOSTNAME2>

<SID2>.thread=2

<SID2>.undo_tablespace=UNDOTBS2

<SID2>.cluster_database = TRUE