Oracle10g RAC環境下DataGuard備庫搭建例項

maojinyu發表於2011-04-28

為一個RAC搭建standby和單節點搭建方法基本一致,我們可以把RAC看成是一個單節點的資料庫,只需要保證所有節點的日誌能傳送到備庫即可。


一、在備庫伺服器安裝ORACLE軟體

只安裝軟體,不要建立資料庫。ORACLE軟體版本和主庫保持一致。

二、修改主庫引數

節點1執行:

SQL> show parameter spfile

NAME TYPE VALUE

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

spfile string /dev/raw/raw14

節點2執行:

SQL> show parameter spfile

NAME TYPE VALUE

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

spfile string /dev/raw/raw14

可見,在本例中,RAC各節點共用一個spfile,所以,我們修改引數時,可以只需在一個節點下修改就可以了。

--強制資料庫LOGGING

SQL> ALTER DATABASE FORCE LOGGING;

Database altered.

--修改DATAGUARD相關引數

SQL> ALTER SYSTEM SET DB_UNIQUE_NAME=primary scope=spfile;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(primary,standby)' scope=spfile;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/soft/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=primary' scope=spfile;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby' scope=spfile;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1=ENABLE scope=spfile;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE scope=spfile;

System altered.

SQL> ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE scope=spfile;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' scope=spfile;

System altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=4 scope=spfile;

System altered.

SQL> ALTER SYSTEM SET COMPATIBLE = '10.2.0.3' scope=spfile;

System altered.

--以下幾個引數是為了SWITCH OVER用的,是可選引數。

--但是為了以後可能發生的SWITCH OVER更方便,應該養成設定這些引數的習慣

SQL> ALTER SYSTEM SET FAL_CLIENT = PRIMARY SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET FAL_SERVER = STANDBY SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT =AUTO SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/soft/oradata/rac/','/dev/raw/' SCOPE=SPFILE;

System altered.

SQL> ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/soft/oradata/rac/','/dev/raw/' SCOPE=SPFILE;

System altered.

--在本文測試環境下,由於主庫和備庫路徑不一致,所以要設定路徑轉換引數。

三、修改主庫為歸檔模式

1--關閉所有例項

--注意:修改以上引數後,必須把所有例項都關閉。否則在啟動例項的時候可能會導致錯誤:

--ORA-00600: internal error code, arguments: [kccsbck_first], [2], [2241198041],

[], [], [], [], []

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

2、修改為歸檔模式

--關閉所有節點

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

--在其中一個節點啟用歸檔

SQL> startup mount

ORACLE instance started.

Total System Global Area 159383552 bytes

Fixed Size 1260672 bytes

Variable Size 79692672 bytes

Database Buffers 75497472 bytes

Redo Buffers 2932736 bytes

Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

10GR2以前,在RAC環境下修改歸檔必須先把設定引數cluster_database=false,把資料庫設定為歸檔後再把該引數設定為true,但這個步驟在10GR2可以省略。

四、備份資料庫

1、備份資料庫

備份操作在節點1(rac1)上執行。

由於歸檔在不同的節點下,故要連線所有節點進行備份:

[oracle@rac1 ~]$ $ORACLE_HOME/bin/rman target /

Recovery Manager: Release 10.2.0.3.0 - Production on Wed Apr 30 14:48:23 2008

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

connected to target database: RAC (DBID=2232067446)

RMAN> run

2> {

3> allocate channel c1 device type disk format '/soft/backup/%U' connect sys/test@rac1;

4> allocate channel c2 device type disk format '/soft/backup/%U' connect sys/test@rac2;

5> backup database plus archivelog delete all input;

6> }

using target database control file instead of recovery catalog

allocated channel: c1

channel c1: sid=134 instance=rac1 devtype=DISK

allocated channel: c2

channel c2: sid=141 instance=rac2 devtype=DISK

Starting backup at 30-APR-08

current log archived

channel c1: starting archive log backupset

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

input archive log thread=1 sequence=80 recid=1 stamp=653247673

input archive log thread=1 sequence=81 recid=4 stamp=653268228

input archive log thread=1 sequence=82 recid=5 stamp=653353066

channel c1: starting piece 1 at 30-APR-08

channel c2: starting archive log backupset

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

input archive log thread=1 sequence=85 recid=13 stamp=653409646

input archive log thread=2 sequence=42 recid=2 stamp=653248818

input archive log thread=2 sequence=43 recid=3 stamp=653250118

input archive log thread=2 sequence=46 recid=10 stamp=653353763

input archive log thread=2 sequence=47 recid=11 stamp=653354798

input archive log thread=2 sequence=48 recid=12 stamp=653409644

input archive log thread=2 sequence=49 recid=16 stamp=653410122

channel c2: starting piece 1 at 30-APR-08

channel c2: finished piece 1 at 30-APR-08

piece handle=/soft/backup/02jf4fql_1_1 tag=TAG20080430T144854 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:05

channel c2: deleting archive log(s)

archive log filename=/soft/archivelog/1_85_644085430.arc recid=13 stamp=653409646

archive log filename=/soft/archivelog/2_42_644085430.arc recid=2 stamp=653248818

archive log filename=/soft/archivelog/2_43_644085430.arc recid=3 stamp=653250118

archive log filename=/soft/archivelog/2_46_644085430.arc recid=10 stamp=653353763

archive log filename=/soft/archivelog/2_47_644085430.arc recid=11 stamp=653354798

archive log filename=/soft/archivelog/2_48_644085430.arc recid=12 stamp=653409644

archive log filename=/soft/archivelog/2_49_644085430.arc recid=16 stamp=653410122

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/01jf4fqq_1_1 tag=TAG20080430T144854 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:14

channel c1: deleting archive log(s)

archive log filename=/soft/archivelog/1_80_644085430.arc recid=1 stamp=653247673

archive log filename=/soft/archivelog/1_81_644085430.arc recid=4 stamp=653268228

archive log filename=/soft/archivelog/1_82_644085430.arc recid=5 stamp=653353066

channel c1: starting archive log backupset

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

input archive log thread=1 sequence=83 recid=6 stamp=653353068

input archive log thread=1 sequence=84 recid=9 stamp=653353575

input archive log thread=1 sequence=86 recid=14 stamp=653409966

input archive log thread=1 sequence=87 recid=15 stamp=653410123

input archive log thread=2 sequence=44 recid=7 stamp=653353071

input archive log thread=2 sequence=45 recid=8 stamp=653353072

channel c1: starting piece 1 at 30-APR-08

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/03jf4fr9_1_1 tag=TAG20080430T144854 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:02

channel c1: deleting archive log(s)

archive log filename=/soft/archivelog/1_83_644085430.arc recid=6 stamp=653353068

archive log filename=/soft/archivelog/1_84_644085430.arc recid=9 stamp=653353575

archive log filename=/soft/archivelog/1_86_644085430.arc recid=14 stamp=653409966

archive log filename=/soft/archivelog/1_87_644085430.arc recid=15 stamp=653410123

archive log filename=/soft/archivelog/2_44_644085430.arc recid=7 stamp=653353071

archive log filename=/soft/archivelog/2_45_644085430.arc recid=8 stamp=653353072

Finished backup at 30-APR-08

Starting backup at 30-APR-08

channel c1: starting full datafile backupset

channel c1: specifying datafile(s) in backupset

input datafile fno=00001 name=/dev/raw/raw1

input datafile fno=00005 name=/dev/raw/raw7

input datafile fno=00003 name=/dev/raw/raw2

channel c1: starting piece 1 at 30-APR-08

channel c2: starting full datafile backupset

channel c2: specifying datafile(s) in backupset

input datafile fno=00002 name=/dev/raw/raw3

input datafile fno=00004 name=/dev/raw/raw5

channel c2: starting piece 1 at 30-APR-08

channel c2: finished piece 1 at 30-APR-08

piece handle=/soft/backup/05jf4frg_1_1 tag=TAG20080430T144919 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:43

channel c2: starting full datafile backupset

channel c2: specifying datafile(s) in backupset

including current control file in backupset

channel c2: starting piece 1 at 30-APR-08

channel c2: finished piece 1 at 30-APR-08

piece handle=/soft/backup/06jf4ft0_1_1 tag=TAG20080430T144919 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:22

channel c2: starting full datafile backupset

channel c2: specifying datafile(s) in backupset

including current SPFILE in backupset

channel c2: starting piece 1 at 30-APR-08

channel c2: finished piece 1 at 30-APR-08

piece handle=/soft/backup/07jf4ftm_1_1 tag=TAG20080430T144919 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:06

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/04jf4frg_1_1 tag=TAG20080430T144919 comment=NONE

channel c1: backup set complete, elapsed time: 00:01:13

Finished backup at 30-APR-08

Starting backup at 30-APR-08

current log archived

channel c1: starting archive log backupset

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

input archive log thread=1 sequence=88 recid=17 stamp=653410237

channel c1: starting piece 1 at 30-APR-08

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/08jf4fv9_1_1 tag=TAG20080430T145120 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:04

channel c1: deleting archive log(s)

archive log filename=/soft/archivelog/1_88_644085430.arc recid=17 stamp=653410237

channel c1: starting archive log backupset

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

input archive log thread=2 sequence=50 recid=18 stamp=653410279

channel c1: starting piece 1 at 30-APR-08

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/09jf4fvf_1_1 tag=TAG20080430T145120 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:04

channel c1: deleting archive log(s)

archive log filename=/soft/archivelog/2_50_644085430.arc recid=18 stamp=653410279

Finished backup at 30-APR-08

released channel: c1

released channel: c2

2、生成備庫控制檔案

RMAN> run

2> {

3> allocate channel c1 device type disk format '/soft/backup/CON_%U';

4> backup current controlfile for standby;

5> }

allocated channel: c1

channel c1: sid=131 instance=rac1 devtype=DISK

Starting backup at 30-APR-08

channel c1: starting full datafile backupset

channel c1: specifying datafile(s) in backupset

including standby control file in backupset

channel c1: starting piece 1 at 30-APR-08

channel c1: finished piece 1 at 30-APR-08

piece handle=/soft/backup/CON_0ajf4gqi_1_1 tag=TAG20080430T150554 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:12

Finished backup at 30-APR-08

released channel: c1

為一個RAC搭建standby和單節點搭建方法基本一致,我們可以把RAC看成是一個單節點的資料庫,只需要保證所有節點的日誌能傳送到備庫即可。


五、備庫環境準備

1、在備庫新增指向主庫的tnsnames

在備庫的tnsnames.ora新增如下內容:

primary =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.11)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.22)(PORT = 1521))

(LOAD_BALANCE = yes)

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = primary)

(FAILOVER_MODE =

(TYPE = SELECT)

(METHOD = BASIC)

(RETRIES = 180)

(DELAY = 5)

)

)

)2、在備庫建立相關目錄

包括adump,bdump,cdump,udump及資料檔案目錄等。

3、複製主庫的密碼檔案到備庫上

--複製rac1的密碼檔案到備庫的$ORACLE_HOME/dbs下,並把該密碼檔案修改為orapwd。這裡我的sid就用rac1,所以,不用改名。

[oracle@rac1 dbs]$ scp orapwrac1 172.25.0.35:`pwd`

orapwrac1 100% 1536 1.5KB/s 00:00

4、配置備庫的監聽

[oracle@standby admin]$ more listener.ora

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = standby)

(ORACLE_HOME = /opt/oracle/product/10.2/database)

(SID_NAME = rac1)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521))

)

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))

)

)

啟動備庫監聽:lsnrctl start

5、設定備庫引數檔案

從主庫rac1上根據spfile建立一個pfile檔案,並傳到備庫上。

SQL> create pfile from spfile;

File created.

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production

With the Partitioning, Real Application Clusters and Data Mining options

[oracle@rac1 ~]$ cd $ORACLE_HOME/dbs

[oracle@rac1 dbs]$ scp initrac1.ora 172.25.0.35:`pwd`

initrac1.ora

在備庫上修改引數檔案:

Ø 刪除所有非"*"打頭的引數設定及rac相關引數

Ø 設定dataguard引數

修改後引數如下:

[oracle@standby dbs]$ more initrac1.ora

*.audit_file_dest='/opt/oracle/admin/rac/adump'

*.background_dump_dest='/opt/oracle/admin/rac/bdump'

*.compatible='10.2.0.3'

*.control_files='/soft/oradata/rac/control01.ctl','/soft/oradata/rac/control02.ctl','/soft/oradata/rac/control03.ctl'

*.core_dump_dest='/opt/oracle/admin/rac/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_file_name_convert='/DEV/RAW/','/SOFT/ORADATA/RAC/'

*.db_name='rac'

*.db_unique_name='STANDBY'

*.fal_client='STANDBY'

*.fal_server='PRIMARY'

*.job_queue_processes=10

*.log_archive_config='DG_CONFIG=(primary,standby)'

*.log_archive_dest_1='LOCATION= /soft/oradata/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'

*.log_archive_dest_2='SERVICE=primary LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

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

*.log_archive_max_processes=4

*.log_file_name_convert='/DEV/RAW/','/SOFT/ORADATA/RAC/'

*.open_cursors=300

*.pga_aggregate_target=16777216

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_max_size=157286400

*.sga_target=157286400

*.standby_file_management='AUTO'

*.undo_management='AUTO'

undo_tablespace='UNDOTBS1'

*.user_dump_dest='/opt/oracle/admin/rac/udump'

以上有些引數非必須設定的,但是為了switchover更方便,建議都修改上。

Undo表空間保留其中一個就可以。

路徑轉換相關引數要設定對,否則會報錯。

6、把備庫啟動到nomount狀態

[oracle@standby ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.3.0 - Production on Wed Apr 30 18:42:39 2008

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

Connected to an idle instance.

SQL> startup nomount

ORACLE instance started.

Total System Global Area 159383552 bytes

Fixed Size 1260672 bytes

Variable Size 62915456 bytes

Database Buffers 92274688 bytes

Redo Buffers 2932736 bytes

7、從主庫複製備份到備庫上

之前備份的所有檔案都複製到備庫上,路徑要和主庫備份路徑保持一致。如果不一致,linux下可以用ln的方式解決。

注意:兩個節點都有歸檔的備份,要把這些備份都複製到備庫上。

RAC1

[oracle@rac1 backup]$ scp * 172.25.0.35:`pwd`

01jf4fqq_1_1 100% 23MB 3.8MB/s 00:06

03jf4fr9_1_1 100% 194KB 194.0KB/s 00:00

04jf4frg_1_1 100% 315MB 3.4MB/s 01:34

08jf4fv9_1_1 100% 13KB 13.0KB/s 00:00

09jf4fvf_1_1 100% 4608 4.5KB/s 00:00

CON_0ajf4gqi_1_1 100% 15MB 3.7MB/s 00:04

RAC2

[oracle@rac2 backup]$ scp * 172.25.0.35:`pwd`

02jf4fql_1_1 100% 7145KB 3.5MB/s 00:02

05jf4frg_1_1 100% 175MB 3.4MB/s 00:52

06jf4ft0_1_1 100% 15MB 1.5MB/s 00:10

07jf4ftm_1_1 100% 96KB 96.0KB/s 00:00

、恢復備庫

1、在主庫新增指向備庫的tnsname

在主庫的tnsnames.ora新增如下內容:

STANDBY =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST =200.200.200.123)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = standby)

)

2、在主庫執行,利用auxiliary來恢復備庫

[oracle@rac1 ~]$ $ORACLE_HOME/bin/rman target / auxiliary sys/6212327@standby

Recovery Manager: Release 10.2.0.3.0 - Production on Wed Apr 30 19:37:05 2008

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

connected to target database: RAC (DBID=2232067446)

connected to auxiliary database: RAC (not mounted)

RMAN> run

{

allocate channel c1 device type disk format '/soft/backup/%U' connect sys/6212327@rac1;

2> 3> 4> allocate channel c2 device type disk format '/soft/backup/%U' connect sys/6212327@rac2;

5> allocate auxiliary channel ac1 device type disk format '/soft/backup/%U';

6> allocate auxiliary channel ac2 device type disk format '/soft/backup/%U';

7> duplicate target database for standby;

8> }

using target database control file instead of recovery catalog

allocated channel: c1

channel c1: sid=132 instance=rac1 devtype=DISK

allocated channel: c2

channel c2: sid=134 instance=rac2 devtype=DISK

allocated channel: ac1

channel ac1: sid=155 devtype=DISK

allocated channel: ac2

channel ac2: sid=154 devtype=DISK

Starting Duplicate Db at 30-APR-08

contents of Memory Script:

{

restore clone standby controlfile;

sql clone 'alter database mount standby database';

}

executing Memory Script

Starting restore at 30-APR-08

channel ac1: starting datafile backupset restore

channel ac1: restoring control file

channel ac1: reading from backup piece /soft/backup/CON_0ajf4gqi_1_1

channel ac1: restored backup piece 1

piece handle=/soft/backup/CON_0ajf4gqi_1_1 tag=TAG20080430T150554

channel ac1: restore complete, elapsed time: 00:00:04

output filename=/soft/oradata/rac/control01.ctl

output filename=/soft/oradata/rac/control02.ctl

output filename=/soft/oradata/rac/control03.ctl

Finished restore at 30-APR-08

sql statement: alter database mount standby database

contents of Memory Script:

{

set newname for tempfile 1 to

"/soft/oradata/rac/raw6";

switch clone tempfile all;

set newname for datafile 1 to

"/soft/oradata/rac/raw1";

set newname for datafile 2 to

"/soft/oradata/rac/raw3";

set newname for datafile 3 to

"/soft/oradata/rac/raw2";

set newname for datafile 4 to

"/soft/oradata/rac/raw5";

set newname for datafile 5 to

"/soft/oradata/rac/raw7";

restore

check readonly

clone database

;

}

executing Memory Script

executing command: SET NEWNAME

renamed temporary file 1 to /soft/oradata/rac/raw6 in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 30-APR-08

channel ac1: starting datafile backupset restore

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

restoring datafile 00002 to /soft/oradata/rac/raw3

restoring datafile 00004 to /soft/oradata/rac/raw5

channel ac1: reading from backup piece /soft/backup/05jf4frg_1_1

channel ac2: starting datafile backupset restore

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

restoring datafile 00001 to /soft/oradata/rac/raw1

restoring datafile 00003 to /soft/oradata/rac/raw2

restoring datafile 00005 to /soft/oradata/rac/raw7

channel ac2: reading from backup piece /soft/backup/04jf4frg_1_1

channel ac1: restored backup piece 1

piece handle=/soft/backup/05jf4frg_1_1 tag=TAG20080430T144919

channel ac1: restore complete, elapsed time: 00:01:22

channel ac2: restored backup piece 1

piece handle=/soft/backup/04jf4frg_1_1 tag=TAG20080430T144919

channel ac2: restore complete, elapsed time: 00:01:32

Finished restore at 30-APR-08

contents of Memory Script:

{

switch clone datafile all;

}

executing Memory Script

datafile 1 switched to datafile copy

input datafile copy recid=6 stamp=653426781 filename=/soft/oradata/rac/raw1

datafile 2 switched to datafile copy

input datafile copy recid=7 stamp=653426781 filename=/soft/oradata/rac/raw3

datafile 3 switched to datafile copy

input datafile copy recid=8 stamp=653426781 filename=/soft/oradata/rac/raw2

datafile 4 switched to datafile copy

input datafile copy recid=9 stamp=653426781 filename=/soft/oradata/rac/raw5

datafile 5 switched to datafile copy

input datafile copy recid=10 stamp=653426781 filename=/soft/oradata/rac/raw7

Finished Duplicate Db at 30-APR-08

released channel: c1

released channel: c2

released channel: ac1

released channel: ac2

從日誌可以看到,oracle先根據引數檔案把控制檔案恢復到合適位置,然後再根據db_file_name_cover把資料檔案恢復到合適位置。

七、後續工作

1、把備庫至於恢復狀態:

[oracle@standby admin]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.3.0 - Production on Wed Apr 30 19:40:59 2008

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

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production

With the Partitioning, Oracle Label Security and Data Mining options

SQL> alter database recover managed standby database disconnect from session;

Database altered

此時觀察備庫的alert檔案,可以發現有很多類似的資訊:

Errors in file /opt/oracle/admin/rac/bdump/rac1_mrp0_10825.trc:

ORA-00313: open failed for members of log group 4 of thread 2

ORA-00312: online log 4 thread 2: '/soft/oradata/rac/raw11'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

Clearing online redo logfile 4 /soft/oradata/rac/raw11

Clearing online log 4 of thread 2 sequence number 50

這是正常的,在第一次置於recover狀態的時候,備庫會生成對應的online redo log

2、在備庫新增standby redo log

Standby redo logarchivelog方式有更大的優勢,且在最大保護、最大可用、實時恢復的情況下必須有standby redo log

Standby redo log的組數一般為(N +1)* thread# N分別為每個thread#的聯機日誌組數)。在本例,每一個thread的聯機日誌都是2組,所以,需要新增6standby redo log

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 ('/soft/oradata/rac/slog4.ora') SIZE 52428800;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 ('/soft/oradata/rac/slog5.ora') SIZE 52428800;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 ('/soft/oradata/rac/slog6.ora') SIZE 52428800;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 ('/soft/oradata/rac/slog7.ora') SIZE 52428800;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 ('/soft/oradata/rac/slog8.ora') SIZE 52428800;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 ('/soft/oradata/rac/slog9.ora') SIZE 52428800;

Database altered.

注意:standby redo log的大小必須和聯機日誌一樣。

七、遇到的問題

1FAL[client, MRP0]: Error 12545 connecting to PRIMARY for fetching gap sequence

Wed Apr 30 20:21:23 2008

Errors in file /opt/oracle/admin/rac/bdump/rac1_mrp0_10965.trc:

ORA-12545: Connect failed because target host or object does not exist

Wed Apr 30 20:22:23 2008

FAL[client]: Failed to request gap sequence

GAP - thread 1 sequence 88-88

DBID 2232067446 branch 644085430

FAL[client]: All defined FAL servers have been attempted.

這個問題和gap有關, 備庫嘗試拿gap的時候,發現不能連線主庫。這個問題是RAC的監聽造成的,參考yangtingkun的解決方法,修改兩個引數即可:

ALTER SYSTEM SET LOCAL_LISTENER = '(ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.11)(PORT = 1521))' SID = 'rac1';

ALTER SYSTEM SET LOCAL_LISTENER = '(ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.22)(PORT = 1521))' SID = 'rac2';

2Wed Apr 30 20:28:51 2008

FAL[client]: Failed to request gap sequence

GAP - thread 1 sequence 88-88

DBID 2232067446 branch 644085430

FAL[client]: All defined FAL servers have been attempted.

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

Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization

parameter is defined to a value that is sufficiently large

enough to maintain adequate log switch information to resolve

archivelog gaps.

這個問題還是和gap有關。備庫現在需要從主庫上拿sequence 88這個歸檔,但這個歸檔在前面做備份的時候刪除了。解決方法是從備份還原這個歸檔:

RMAN> restore archivelog sequence 88;

Starting restore at 30-APR-08

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=138 instance=rac1 devtype=DISK

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=88

channel ORA_DISK_1: reading from backup piece /soft/backup/08jf4fv9_1_1

channel ORA_DISK_1: restored backup piece 1

piece handle=/soft/backup/08jf4fv9_1_1 tag=TAG20080430T145120

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

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9907339/viewspace-1049176/,如需轉載,請註明出處,否則將追究法律責任。

相關文章