RAC環境下建立物理DATAGUARD(1)

space6212發表於2019-05-19

為一個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

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

相關文章