在RAC下安裝配置OGG

myownstars發表於2013-06-02

有多種方案

1

共享磁碟—ACFS/DBFS/OCFS2

可由任何一個節點啟動OGG,若該節點crash,可由其他節點重啟managerOGG程式;若本地節點的DB crash,則先停止其manager程式然後在其他節點啟動

2

本地磁碟

不支援failover,如果本地節點失效則無法獲取checkpoint資訊

3

異機安裝

GG透過tnsname連線到RACoracle日誌檔案必須位於共享磁碟以便extract讀取

 

一般選項安裝於共享磁碟,/u02ACFS檔案系統,安裝步驟與單例項類似,新增extract程式時應指定thread數量;

 

連線ASM

如果RAC使用ASM儲存檔案,則配置Extract時連線應指向ASM

對於10205/11202同時OGG版本>=11,採用DBLOGREADER API可直接連通資料庫,其他版本則透過SQLNETSYS ASM使用者登入;

--透過ASMUSER連線ASM時,extrat程式的buffer28672位元組,而DBLOGREADER API預設為1024000位元組,其extract相應配置為tranlogoptions dblogreader

 

如果資料量巨大,對於10R2或更高版本可使用BEQ協議,相比傳統的listener節省了TCP/IP開銷,OGG必須執行於db server

 

使用傳統sqlnet配置

1 ASM透過db listener提供遠端連線必須顯示的加入監聽器配置檔案

2 Extract引數檔案必須包含連線ASM例項的配置

 

GGSCI (raclinux1.gj.com) 25> view params extcdc

extract extcdc

tranlogoptions asmuser sys@ASM, asmpassword sys1

userid ogg_extract, password ogg_extract

rmthost raclinux1, mgrport 7809

rmttrail ./dirdat/aa

 

使用BEQDBLOGREADER時配置如下

--tnsname

ORCL_BEQ =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = BEQ)

(PROGRAM=oracle)

(ARGV0 = oracleORCL)

(ARGS=‘(DESCRIPTION=(LOCAL=YES)(ADDRESS =(PROTOCOL=BEQ)))’)

)

(CONNECT_DATA = (SERVICE_NAME = ORCL))

)

--extract引數檔案

EXTRACT EASM

EXTTRAIL ./dirdat/ea

USERID gguser@ORCL_BEQ, PASSWORD Oracle1

TRANLOGOPTIONS BUFSIZE 4096000

TRANLOGOPTIONS DBLOGREADER, DBLOGREADERBUFSIZE 4096000

TABLE amer.*;

 

Extract ASM Connection Methods [ID 1390268.1]

 

 

安裝完畢後,為保證OGG可以failover,須將其manager程式註冊為clusterware資源,以下適用於11R2

1

新增應用VIP

$GRID_HOME/bin/appvipcfg create -network=1 -ip=10.1.41.93 -vipname=mvggatevip -user=root

此時VIP屬主為root,賦予許可權給oracle

$GRID_HOME/bin/crsctl setperm resource mvggatevip -u user:oracle:r-x

oracle使用者啟動

$GRID_HOME/bin/crsctl start resource mvggatevip

檢視VIP執行情況

GRID_HOME/bin/crsctl status resource mvggatevip

 

2

部署agent指令碼

Clusterware透過agent執行相應資源

將指令碼11gr2_gg_action.scr複製到每個節點相同目錄,其至少包含5個選項:start/stop/check/clean/abort

Chmod +X 11gr2_gg_action.scr

Oracle Clusterware runs resource-specific commands through an entity called an agent. The agent script. must be able to accept 5 parameter values: start, stop, check, clean and abort (optional).

Save the script. in a file and copy it to every node in the cluster into the same directory

 

3

註冊到叢集

$GRID_HOME/bin/crsctl add resource ggateapp -type cluster_resource -attr "ACTION_SCRIPT=/mnt/acfs/oracle/grid/11gr2_gg_action.scr, CHECK_INTERVAL=30, START_DEPENDENCIES='hard(mvggatevip) pullup(mvggatevip)', STOP_DEPENDENCIES='hard(mvggatevip)'"

如果OGGGRID分屬不同使用者,須將該應用屬主設定為OGG使用者(假定mvandewiel)

--root使用者執行

$GRID_HOME/bin/crsctl setperm resource ggateapp -o mvandewiel

 

4

啟動應用

$GRID_HOME/bin/crsctl start resource ggateapp

$GRID_HOME/bin/crsctl status resource ggateapp

NAME=ggateapp

TYPE=cluster_resource

TARGET=ONLINE

STATE=ONLINE on coe-02

 

5

重定向

[oracle@coe-02 grid]$ crsctl relocate resource ggateapp -f

CRS-2673: Attempting to stop 'ggateapp' on 'coe-01'

CRS-2677: Stop of 'ggateapp' on 'coe-01' succeeded

CRS-2673: Attempting to stop 'mvggatevip' on 'coe-01'

CRS-2677: Stop of 'mvggatevip' on 'coe-01' succeeded

CRS-2672: Attempting to start 'mvggatevip' on 'coe-02'

CRS-2676: Start of 'mvggatevip' on 'coe-02' succeeded

CRS-2672: Attempting to start 'ggateapp' on 'coe-02'

CRS-2676: Start of 'ggateapp' on 'coe-02' succeeded

 

清空資源

先以oracle使用者停止相應資源

GRID_HOME/bin/crsctl stop resource ggateapp

GRID_HOME/bin/crsctl stop resource mvggatevip

root使用者刪除資源

$GRID_HOME/bin/crsctl delete resource ggateapp

GRID_HOME/bin/appvipcfg delete -vipname=mvggatevip

刪除11gr2_gg_action.scr指令碼

 

 

指令碼

#!/bin/sh

#set the Oracle Goldengate installation directory

export GGS_HOME=/cloudfs/goldengate

#set the oracle home to the database to ensure GoldenGate will get the

#right environment settings to be able to connect to the database

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

#specify delay after start before checking for successful start

start_delay_secs=5

#Include the GoldenGate home in the library path to start GGSCI

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:${GGS_HOME}:${LD_LIBRARY_PATH}

#check_process validates that a manager process is running at the PID

#that GoldenGate specifies.

  

check_process () {

if ( [ -f "${GGS_HOME}/dirpcs/MGR.pcm" ] )

then

  pid=`cut -f8 "${GGS_HOME}/dirpcs/MGR.pcm"`

  if [ ${pid} = `ps -e |grep ${pid} |grep mgr |cut -d " " -f2` ]

  then

    #manager process is running on the PID exit success

    exit 0

  else

  if [ ${pid} = `ps -e |grep ${pid} |grep mgr |cut -d " " -f1` ]

  then

    #manager process is running on the PID exit success

    exit 0

  else

    #manager process is not running on the PID

    exit 1

  fi

fi

else

  #manager is not running because there is no PID file

  exit 1

fi

}

  

#call_ggsci is a generic routine that executes a ggsci command

call_ggsci () {

  ggsci_command=$1

  ggsci_output=`${GGS_HOME}/ggsci < < EOF

  ${ggsci_command}

  exit

  EOF`

}

  

case $1 in

'start')

  #start manager

  call_ggsci 'start manager'

  #there is a small delay between issuing the start manager command

  #and the process being spawned on the OS. wait before checking

  sleep ${start_delay_secs}

  #check whether manager is running and exit accordingly

  check_process

  ;;

'stop')

  #attempt a clean stop for all non-manager processes

  #call_ggsci 'stop er *'

  #ensure everything is stopped

  call_ggsci 'stop er *!'

  #call_ggsci 'kill er *'

  #stop manager without (y/n) confirmation

  call_ggsci 'stop manager!'

  #exit success

  exit 0

  ;;

'check')

  check_process

  ;;

'clean')

  #attempt a clean stop for all non-manager processes

  #call_ggsci 'stop er *'

  #ensure everything is stopped

  #call_ggsci 'stop er *!'

  #in case there are lingering processes

  call_ggsci 'kill er *'

  #stop manager without (y/n) confirmation

  call_ggsci 'stop manager!'

  #exit success

  exit 0

  ;;

'abort')

  #ensure everything is stopped

  call_ggsci 'stop er *!'

  #in case there are lingering processes

  call_ggsci 'kill er *'

  #stop manager without (y/n) confirmation

  call_ggsci 'stop manager!'

  #exit success

  exit 0

  ;;

esac

 

 

 

增刪RAC節點需重新配置extract  1267901.1

增加節點, 需修改extractthread

1 增加新日誌 alter database add logfile thread#

2 停止extract程式,獲取當前檢查點資訊info ext , showch,然後刪除該extractdelete ext

3 重新新增extract程式,add ext , begin now, tranlog, threads

4 依據step2資訊修改其檢查點alter extract [thread n] extseqno <>, extrba <>/alter extract [thread n] ioextseqno <>, ioextrba <>

5 重啟extract程式

 

Extract程式有相應引數processthreads select/except 用於指定或排除候選log thread

 

增刪節點後,OGG threadRAC thread的對映關係可能發生變動1342635.1

RAC thread的順序遵從select distinct thread# from v$log的輸出,而OGG thread永遠從1N遞增

Before node addition:
====================
RAC THREAD#               OGG thread
-----------------      --------------
   5                -             1
   1                -             2
   2                -             3
   3                -             4
   4                -             5

 

After  node addition:
====================
The corresponding thread mapping for Golden Gate is identified as given below:

RAC THREAD#                OGG thread
-----------                ----------
   6                -           1
   5                -           2
   1                -           3
   2                -           4
   3                -           5
   4                -           6

RAC thread 6為新增節點,其歸檔日誌應從0開始,則OGG thread#1的檢查點應指向RAC thread#60號日誌

 

 

 

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

相關文章