日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

修改自:收錄的一篇很詳細(xì)很全的OGG配置文檔

 nanatsg 2019-06-28

1       GoldenGate簡要說明

GoldenGate現(xiàn)在是業(yè)內(nèi)成熟的數(shù)據(jù)容災(zāi)與復(fù)制產(chǎn)品,經(jīng)過多年的發(fā)展與完善,現(xiàn)在已經(jīng)成為業(yè)內(nèi)事實(shí)上的標(biāo)準(zhǔn)之一。

GoldenGate軟件是一種基于日志的結(jié)構(gòu)化數(shù)據(jù)復(fù)制軟件,它通過解析源數(shù)據(jù)庫在線日志或歸檔日志獲得數(shù)據(jù)的增刪改變化,再將這些變化應(yīng)用到目標(biāo)數(shù)據(jù)庫,實(shí)現(xiàn)源數(shù)據(jù)庫與目標(biāo)數(shù)據(jù)庫同步。

1.1  Golden Gate技術(shù)結(jié)構(gòu)

GoldenGate主要包含Manager進(jìn)程、Extract進(jìn)程、Pump進(jìn)程、Replicate進(jìn)程,下面對其一一說明:

Manager進(jìn)程是GoldenGate的控制進(jìn)程,它主要作用有以下幾個(gè)方面:啟動(dòng)、監(jiān)控、重啟GoldenGate的其他進(jìn)程,報(bào)告錯(cuò)誤及時(shí)間,分配數(shù)據(jù)存儲(chǔ)空間,發(fā)布閥值報(bào)告等。

Extract進(jìn)程運(yùn)行在數(shù)據(jù)庫源端,負(fù)責(zé)從源端數(shù)據(jù)表或日志中捕獲數(shù)據(jù)。Extract進(jìn)程利用其內(nèi)在的checkpoint機(jī)制,周期性地檢查并記錄其讀寫的位置,通常是寫入到本地的trail文件。這種機(jī)制是為了保證如果Extract進(jìn)程終止或者操作系統(tǒng)宕機(jī),我們重啟Extract進(jìn)程后,GoldenGate能夠恢復(fù)到以前的狀態(tài),從上一個(gè)斷點(diǎn)處繼續(xù)往下運(yùn)行,而不會(huì)有任何數(shù)據(jù)損失。

Pump進(jìn)程運(yùn)行在數(shù)據(jù)庫源端,其作用非常簡單。如果源端使用了本地trail文件,那么Pump進(jìn)程就會(huì)把Trail文件以數(shù)據(jù)塊的形式通過TCP/IP協(xié)議發(fā)送到目標(biāo)端,我們下面的配置都是這種方式。Pump進(jìn)程本質(zhì)是Extract進(jìn)程的一種特殊形式,如果不使用Trail文件,那么Extract進(jìn)程在抽取完數(shù)據(jù)后,直接投遞到目標(biāo)端。

與Pump進(jìn)程相對應(yīng)的叫Server Collector進(jìn)程,這個(gè)進(jìn)程不需要引起我們關(guān)注,因?yàn)樵趯?shí)際操作過程中無需對其進(jìn)行任何配置,它運(yùn)行在目標(biāo)端,任務(wù)就是把Extract/Pump進(jìn)程投遞過來的數(shù)據(jù)塊重新組裝成Trail文件。

Replicate進(jìn)程運(yùn)行在目標(biāo)端,是數(shù)據(jù)投遞的最后一站,負(fù)責(zé)讀取目標(biāo)端Trail文件中的內(nèi)容,并將其解析為DML或DDL語句,然后應(yīng)用到目標(biāo)數(shù)據(jù)庫中。

1.2  Golden Gate拓?fù)浣Y(jié)構(gòu)

GoldenGate提供了靈活的應(yīng)用方案,基于其先進(jìn)、靈活的技術(shù)架構(gòu)可以根據(jù)用戶需求組成各種拓?fù)浣Y(jié)構(gòu),

根據(jù)實(shí)際需求情況,我們需要進(jìn)行的是一對一復(fù)制,且只是復(fù)制部分表數(shù)據(jù),所以這里僅探討一對一復(fù)制的安裝配置,而且對于DDL復(fù)制的支持這里也不做研究。

2       單機(jī)à單機(jī)復(fù)制配置

2.1  環(huán)境簡介

性質(zhì)

IP

系統(tǒng)

ORACLE版本

源端

192.168.100.3

RHEL6.5

11.2.0.4

目標(biāo)端

192.168.100.4

RHEL6.5

11.2.0.4

2.2  源端安裝GoldenGate

創(chuàng)建GoldenGate安裝目錄并解壓安裝文件(oracle用戶)

mkdir /home/oracle/ogg

unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip

tar -xvf fbo_ggs_Linux_x64_ora11g_64bit.tar

注意:使用的安裝包一定要與平臺(tái)一致

檢查必須的lib包,gg在Linux和unix下安裝,需要oracle的lib環(huán)境以及$ORACLE_HOME/lib下的幾個(gè)包,所以必須安裝在oracle之后,且確保在環(huán)境變量中加入:

export GGATE_HOME=/u01/oracle/ogg

export LD_LIBRARY_PATH=$GGATE_HOME:$ORACLE_HOME/lib

AIX中為LIBPATH

注意:添加后需使參數(shù)文件生效

. .bash_profile

解壓路徑下:
ldd ggsci

安裝GoldenGate

進(jìn)入OGG控制臺(tái)創(chuàng)建OGG工作目錄

然后在安裝目錄下執(zhí)行 ./ggsci  進(jìn)入OGG控制臺(tái)

執(zhí)行命令 create subdirs創(chuàng)建工作目錄,顯示如下:

GGSCI (single1) 1> create subdirs

Creating subdirectories under current directory /home/oracle/ogg

Parameter files                /home/oracle/ogg/dirprm: already exists
Report files                   /home/oracle/ogg/dirrpt: created
Checkpoint files               /home/oracle/ogg/dirchk: created
Process status files           /home/oracle/ogg/dirpcs: created
SQL script files               /home/oracle/ogg/dirsql: created
Database definitions files     /home/oracle/ogg/dirdef: created
Extract data files             /home/oracle/ogg/dirdat: created
Temporary files                /home/oracle/ogg/dirtmp: created
Stdout files                   /home/oracle/ogg/dirout: created

2.3 目標(biāo)端安裝GoldenGate

建立OGG安裝目錄,然后將壓縮包解壓到目錄中,進(jìn)入cmd控制臺(tái),創(chuàng)建工作目錄,

操作步驟顯示如下:

2.4  配置源端數(shù)據(jù)庫

數(shù)據(jù)庫模式配置

源端數(shù)據(jù)庫必須開啟歸檔模式

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     4
Next log sequence to archive   6
Current log sequence           6

如果沒有開啟:

Alter databasearchivelog;

開啟最小附加日志

select supplemental_log_data_min from v$database;

如果沒有開啟:

Alter database add supplemental log data;


源端數(shù)據(jù)庫創(chuàng)建GoldenGate數(shù)據(jù)庫用戶并授權(quán):(我們這里以ogg為例,使用其他亦可)

create user ogg identified by oracle;

grant connect,resource,unlimited tablespace to ogg;

grant execute on utl_file to ogg;

grant select any dictionary,select any table to ogg;

grant alter any table to ogg;

grant flashback any table to ogg;

grant execute on DBMS_FLASHBACK to ogg;

添加表級transdata

GGSCI (single1) 2> dblogin userid ogg,password oracle
Successfully logged into database.

GGSCI (single1) 3> add trandata lm.*

2015-10-31 22:49:14  WARNING OGG-00869  No unique key is defined for table 'LM_T1'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.

Logging of supplemental redo data enabled for table LM.LM_T1.

add trandata:

為表添加附加日志,以便goldengate進(jìn)行redo的抽取以及應(yīng)用。后面添加的是想要同步的用戶及用戶下的表。

2.5  配置源端進(jìn)程組

配置管理進(jìn)程mgr

GGSCI(NDSCDB1) 1> edit param mgr

(粘貼下面這段配置)

PORT 7839

DYNAMICPORTLIST 7840-7939

--AUTOSTART ER *

AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS ./dirdat/*,usecheckpoints, minkeepdays 3

LAGREPORTHOURS 1

LAGINFOMINUTES 30

LAGCRITICALMINUTES 45

MANAGER進(jìn)程參數(shù)配置說明:

PORT指定服務(wù)監(jiān)聽端口;這里以7839為例,默認(rèn)端口為7809

DYNAMICPORTLIST動(dòng)態(tài)端口:可以制定最大256個(gè)可用端口的動(dòng)態(tài)列表,當(dāng)指定的端口不可用時(shí),管理進(jìn)程將會(huì)從列表中選擇一個(gè)可用的端口,源端和目標(biāo)段的CollectorReplicat、GGSCI進(jìn)程通信也會(huì)使用這些端口;

COMMENT注釋行,也可以用--來代替;

AUTOSTART指定在管理進(jìn)程啟動(dòng)時(shí)自動(dòng)啟動(dòng)哪些進(jìn)程;

AUTORESTART自動(dòng)重啟參數(shù)設(shè)置:本處設(shè)置表示每3分鐘嘗試重新啟動(dòng)所有EXTRACT進(jìn)程,共嘗試5次;

PURGEOLDEXTRACTS定期清理trail文件設(shè)置:本處設(shè)置表示對于超過3天的trail文件進(jìn)行刪除。

LAGREPORT、LAGINFO、LAGCRITICAL

定義數(shù)據(jù)延遲的預(yù)警機(jī)制:本處設(shè)置表示MGR進(jìn)程每隔1小時(shí)檢查EXTRACT的延遲情況,如果超過了30分鐘就把延遲作為信息記錄到錯(cuò)誤日志中,如果延遲超過了45分鐘,則把它作為警告寫到錯(cuò)誤日志中。

啟動(dòng)管理進(jìn)程:

GGSCI (single1) 12> start mgr

Manager started.

查看進(jìn)程狀態(tài)可發(fā)現(xiàn) MANAGER狀態(tài)為 RUNNING

GGSCI (single1) 13> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNIN

配置抽取進(jìn)程:

GGSCI (single1) 4> add extract extnd,tranlog ,begin now
EXTRACT added.


GGSCI (single1) 5> add exttrail ./dirdat/nd,extract extnd,megabytes 100
EXTTRAIL added.

Megabytes:指定隊(duì)列大小,本處設(shè)置表示100M。

GGSCI (single1) 6> edit param extnd

(粘貼下面這段配置)

EXTRACT extnd

setenv(NLS_LANG = 'AMERICAN_AMERICA.UTF8')   從哪里來?

SETENV(ORACLE_HOME = '/u01/oracle/oracle/product/10.2.0/db_1')

SETENV(ORACLE_SID = 'single1')

USERID ogg, PASSWORD oracle

--GETTRUNCATES

REPORTCOUNT EVERY 1 MINUTES, RATE

DISCARDFILE ./dirrpt/extnd.dsc,APPEND,MEGABYTES 1024

--THREADOPTIONS  MAXCOMMITPROPAGATIONDELAY 60000 IOLATENS60000

DBOPTIONS  ALLOWUNUSEDCOLUMN

WARNLONGTRANS 2h,CHECKINTERVAL 3m

EXTTRAIL ./dirdat/nd

--TRANLOGOPTIONSEXCLUDEUSER USERNAME

FETCHOPTIONS NOUSESNAPSHOT

TRANLOGOPTIONS  CONVERTUCS2CLOBS

TABLE lm.lm_t1;

添加傳輸進(jìn)程,配置參數(shù)

GGSCI (single1) 8> add extract dpend,exttrailsource ./dirdat/nd
EXTRACT added.


GGSCI (single1) 9> add rmttrail /home/oracle/ogg/dirdat/nd.extrat dpend

ERROR: file portion must be two characters.     ------存文件的路徑必須是兩個(gè)字符。


GGSCI (single1) 11> add rmttrail /home/oracle/ogg/dirdat/nd,extract dpend
RMTTRAIL added.

GGSCI(NDSCDB1) 4> edit params dpend

(粘貼下面這段配置)

EXTRACT dpend

SETENV(NLS_LANG = 'AMERICAN_AMERICA.UTF8')

USERID ogg, PASSWORD oracle

PASSTHRU

RMTHOST 192.168.100.4, MGRPORT 7839, compress

RMTTRAIL /home/oracle/ogg/dirdat/nd

TABLE lm.lm_t1;

抽取進(jìn)程和傳輸進(jìn)程其實(shí)都是EXTRACT進(jìn)程,也可以配置在一個(gè)進(jìn)程完成這兩個(gè)功能,但是當(dāng)網(wǎng)絡(luò)傳輸有問題時(shí),這樣抽取也就不能繼續(xù)運(yùn)行了,所以推薦分開配置為兩個(gè)進(jìn)程;

EXTRACT進(jìn)程參數(shù)配置說明:

SETENV配置系統(tǒng)環(huán)境變量        

USERID/ PASSWORD指定OGG連接數(shù)據(jù)庫的用戶名和密碼,這里使用3.4部分中創(chuàng)建的數(shù)據(jù)庫用戶OGG;

COMMENT注釋行,也可以用--來代替;

TABLE定義需復(fù)制的表,后面需以;結(jié)尾

TABLEEXCLUDE定義需要排除的表,如果在TABLE參數(shù)中使用了通配符,可以使用該參數(shù)指定排除掉得表。

GETUPDATEAFTERS|IGNOREUPDATEAFTERS

是否在隊(duì)列中寫入后影像,缺省復(fù)制

GETUPDATEBEFORES| IGNOREUPDATEBEFORES

是否在隊(duì)列中寫入前影像,缺省不復(fù)制

GETUPDATES|IGNOREUPDATES

是否復(fù)制UPDATE操作,缺省復(fù)制

GETDELETES|IGNOREDELETES

是否復(fù)制DELETE操作,缺省復(fù)制

GETINSERTS|IGNOREINSERTS

是否復(fù)制INSERT操作,缺省復(fù)制

GETTRUNCATES|IGNORETRUNDATES

是否復(fù)制TRUNCATE操作,缺省不復(fù)制;

RMTHOST指定目標(biāo)系統(tǒng)及其GoldengateManager進(jìn)程的端口號,還用于定義是否使用壓縮進(jìn)行傳輸,本例中的compress為壓縮傳輸;

RMTTRAIL指定寫入到目標(biāo)斷的哪個(gè)隊(duì)列;

EXTTRAIL指定寫入到本地的哪個(gè)隊(duì)列;

SQLEXECextract進(jìn)程運(yùn)行時(shí)首先運(yùn)行一個(gè)SQL語句;

PASSTHRU禁止extract進(jìn)程與數(shù)據(jù)庫交互,適用于Data Pump傳輸進(jìn)程;

REPORT定義自動(dòng)定時(shí)報(bào)告;

STATOPTIONS定義每次使用stat時(shí)統(tǒng)計(jì)數(shù)字是否需要重置;

REPORTCOUNT報(bào)告已經(jīng)處理的記錄條數(shù)統(tǒng)計(jì)數(shù)字;

TLTRACE打開對于數(shù)據(jù)庫日志的跟蹤日志;

DISCARDFILE定義discardfile文件位置,如果處理中油記錄出錯(cuò)會(huì)寫入到此文件中;

DBOPTIONS指定對于某種特定數(shù)據(jù)庫所需要的特殊參數(shù);

TRANLOGOPTIONS指定在解析數(shù)據(jù)庫日志時(shí)所需要的特殊參數(shù),例如:對于裸設(shè)備,可能需要加入以下參數(shù) rawdeviceoggset 0

WARNLONGTRANS指定對于超過一定時(shí)間的長交易可以在gsserr.log里面寫入警告信息,本處配置為每隔3分鐘檢查一次場交易,對于超過2小時(shí)的進(jìn)行警告;

2.6  配置目標(biāo)數(shù)據(jù)庫

目標(biāo)庫創(chuàng)建GoldenGate數(shù)據(jù)庫用戶并授權(quán):

create user ogg identified by oracle default tablespace DATA_OL;

grant connect,resource,unlimited tablespace to ogg;

grant execute on utl_file to ogg;

grant select any dictionary,select any table to ogg;

grant alter any table to ogg;

grant flashback any table to ogg;

grant execute on DBMS_FLASHBACK to ogg;

grant insert any table to ogg;

grant delete any table to ogg;

grant update any table to ogg;

添加checkpoint

SQL> create table lm_t1(id number);

然后在參數(shù)文件中輸入

GGSCHEMA ogg

CHECKPOINT TABLE lm2.lm_t1

2.7 配置目標(biāo)端進(jìn)程組

配置管理進(jìn)程

配置復(fù)制進(jìn)程

REPLICAT進(jìn)程參數(shù)配置說明:

ASSUMETARGETDEFS假定兩端數(shù)據(jù)結(jié)構(gòu)一致使用此參數(shù);

SOURCEDEFS假定兩端數(shù)據(jù)結(jié)構(gòu)不一致,使用此參數(shù)指定源端的數(shù)據(jù)結(jié)構(gòu)定義文件,該文件需要由GlodenGate工具產(chǎn)生。

MAP:用于指定源端與目標(biāo)端表的映射關(guān)系;

MAPEXCLUDE用于使用在MAP中使用*匹配時(shí)排除掉指定的表;

REPERROR定義出錯(cuò)以后進(jìn)程的響應(yīng),一般可以定義為兩種:

ABEND,即一旦出現(xiàn)錯(cuò)誤即停止復(fù)制,此為缺省配置;

DISCARD,出現(xiàn)錯(cuò)誤后繼續(xù)復(fù)制,只是把錯(cuò)誤的數(shù)據(jù)放到discard文件中。

DISCARDFILE定義discardfile文件位置,如果處理中油記錄出錯(cuò)會(huì)寫入到此文件中;

SQLEXEC在進(jìn)程運(yùn)行時(shí)首先運(yùn)行一個(gè)SQL語句;

GROUPTRANSOPS將小交易合并成一個(gè)大的交易進(jìn)行提交,減少提交次數(shù),降低系統(tǒng)IO消耗。

MAXTRANSOPS將大交易拆分,每XX條記錄提交一次。

2.8 啟動(dòng)進(jìn)程進(jìn)行數(shù)據(jù)同步

啟動(dòng)源端進(jìn)程組

啟動(dòng)抽取進(jìn)程和傳輸進(jìn)程:

start extnd

start dpend

啟動(dòng)后使用info all查看進(jìn)程狀態(tài),正常status應(yīng)該RUNNING,顯示如下:

GGSCI (NDSCDB1)11> info all

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                     

EXTRACT     RUNNING    DPEND       00:00:00      00:15:32

EXTRACT     RUNNING    EXTND       00:00:00      00:00:04

啟動(dòng)目標(biāo)端進(jìn)程

start repnd

顯示如下:

到此OGG的安裝配置就完成了,可以進(jìn)行數(shù)據(jù)同步測試了。

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

3       RACà單機(jī)復(fù)制配置

3.1  環(huán)境簡介

性質(zhì)

IP

系統(tǒng)

ORACLE版本

源端

10.123.112.201/10.123.112.202

LINUX rhel5 64位

10.2.0.1

目標(biāo)端

10.123.112.235

LINUX rhel5 32位

10.2.0.1

3.2 源端安裝OCFS2集群文件系統(tǒng)

RAC環(huán)境中為了實(shí)現(xiàn)高可用性,需將OGG安裝在集群文件系統(tǒng)中,這樣OGG可以訪問RAC中的所有節(jié)點(diǎn),我們這里測試采用OCFS2文件系統(tǒng)。

從http://oss.oracle.com下載與LINUX內(nèi)核相符的OCFS2 RPM包

LINUX下執(zhí)行uname –r查看系統(tǒng)內(nèi)核版本 eg:

[oracle@node2ocfs]$ uname -r

2.6.18-92.el5

使用ROOT用戶安裝OCFS2的RPM包

[root@node1ocfs]# rpm -ivh ocfs2-tools-1.2.7-1.el5.x86_64.rpm \

ocfs2console-1.2.7-1.el5.x86_64.rpm\

ocfs2-2.6.18-92.el5-1.2.9-1.el5.x86_64.rpm

進(jìn)入OCFS2控制臺(tái)界面

[root@node1 ~]#ocfs2console

在出現(xiàn)的窗體中選擇[Clucster]-[ConfigureNodes]在'NodeConfiguration'對話框中,輸入2個(gè)專用互連的節(jié)點(diǎn)名、IP 地址、端口號后,選擇 [Clucster]-[PropagateCluster Configuration] ,提示'Finished'。

配置后的信息顯示如下:

在集群中的所有節(jié)點(diǎn)上以 root 用戶帳戶的身份運(yùn)行以下命令
    export PATH=$PATH:/sbin:/usr/sbin
    /etc/init.d/o2cb enable

創(chuàng)建ocfs2文件系統(tǒng),其中-N選項(xiàng)用于指明最多允許多少個(gè)節(jié)點(diǎn)同時(shí)使用此文件系統(tǒng):

# mkfs -t ocfs2-N 2 /dev/sdh1

掛載分區(qū):

# mount /dev/sdh1/ggate

配置啟動(dòng)自動(dòng)載入(所有節(jié)點(diǎn)):
    export PATH=$PATH:/sbin:/usr/sbin
    chkconfig --add o2cb
    /etc/init.d/o2cb configure
在/etc/rc.local增加入下內(nèi)容:      

chown -Roracle:dba /ggate
chmod -R 775 /ggate

3.3 源端安裝GoldenGate

GoldenGate安裝目錄(OCFS2目錄/ggate)解壓安裝文件

unzipogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip

tar–xvf fbo_ggs_Linux_x64_ora10g_64bit.tar

設(shè)置環(huán)境變量

在用戶參數(shù)文件中添加以下內(nèi)容:

exportGGATE_HOME=/ggate

exportLD_LIBRARY_PATH=$GGATE_HOME:$ORACLE_HOME/lib

注意:添加后需使參數(shù)文件生效

安裝GoldenGate

進(jìn)入OGG控制臺(tái)創(chuàng)建OGG工作目錄

然后在安裝目錄下執(zhí)行 ./ggsci  進(jìn)入OGG控制臺(tái)

執(zhí)行命令 createsubdirs創(chuàng)建工作目錄,顯示如下:

GGSCI(node1) 1> create subdirs

Creatingsubdirectories under current directory /ggate

Parameterfiles                /ggate/dirprm:already exists

Reportfiles                   /ggate/dirrpt:created

Checkpointfiles               /ggate/dirchk:created

Processstatus files             /ggate/dirpcs: created

SQLscript files               /ggate/dirsql:created

Databasedefinitions files       /ggate/dirdef: created

Extractdata files              /ggate/dirdat: created

Temporaryfiles               /ggate/dirtmp:created

Stdoutfiles                   /ggate/dirout:created

3.4 目標(biāo)端安裝GoldenGate

環(huán)境相同,安裝方法與4.3一致,僅僅是安裝位置不同,安裝過程略,注意安裝包與平臺(tái)一致。

3.5 配置源端數(shù)據(jù)庫

數(shù)據(jù)庫模式配置

源端數(shù)據(jù)庫必須開啟歸檔模式

Alterdatabase archivelog;

開啟最小附加日志

Alterdatabase add supplemental log data;

使用SELECTSUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;

可查看是否開啟了最小附加日志;

源端數(shù)據(jù)庫創(chuàng)建GoldenGate數(shù)據(jù)庫用戶并授權(quán):(我們這里以ogg為例,使用其他亦可)

createuser ogg identified by oracle default tablespace DATA_OL;

grantconnect,resource,unlimited tablespace to ogg;

grantexecute on utl_file to ogg;

grantselect any dictionary,select any table to ogg;

grantalter any table to ogg;

grantflashback any table to ogg;

grantexecute on DBMS_FLASHBACK to ogg;

添加表級transdata

GGSCI(node1) 1> dblogin userid ogg,password oracle

Successfullylogged into database.

GGSCI(node1) 2> add trandata SCOTT.DEPT

Loggingof supplemental redo data enabled for table SCOTT.DEPT.

GGSCI(node1) 3> add trandata SCOTT.EMP

Loggingof supplemental redo data enabled for table SCOTT.EMP.

3.6  配置源端進(jìn)程組

配置管理進(jìn)程mgr

GGSCI(node1) 1> edit param mgr

(粘貼下面這段配置)

PORT7839

DYNAMICPORTLIST7840-7939

--AUTOSTARTER *

AUTORESTARTEXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS./dirdat/*,usecheckpoints, minkeepdays 3

LAGREPORTHOURS1

LAGINFOMINUTES30

LAGCRITICALMINUTES45

參數(shù)說明均與單點(diǎn)配置相同,參考3.5部分

啟動(dòng)管理進(jìn)程:

GGSCI(node1) 2> start mgr

Managerstarted.

GGSCI(node1) 3> info all

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING

配置抽取進(jìn)程:

GGSCI(node1) 6> add extract extnd,tranlog,begin now,threads 2

EXTRACTadded.

GGSCI(node1) 7> add exttrail ./dirdat/nd,extract extnd,megabytes 100

EXTTRAILadded.

GGSCI(node1) 8> edit params extnd

(粘貼下面這段配置)

EXTRACTextnd

SETENV(NLS_LANG = 'AMERICAN_AMERICA.UTF8')

SETENV(ORACLE_HOME = '/u01/app/oracle/product/10.2.0/db_1')

USERID ogg@RAC, PASSWORDoracle

--GETTRUNCATES

REPORTCOUNTEVERY 1 MINUTES, RATE

DISCARDFILE./dirrpt/extnd.dsc,APPEND,MEGABYTES 1024

--THREADOPTIONS  MAXCOMMITPROPAGATIONDELAY 60000 IOLATENS60000

DBOPTIONS  ALLOWUNUSEDCOLUMN

WARNLONGTRANS2h,CHECKINTERVAL 3m

EXTTRAIL./dirdat/nd

--TRANLOGOPTIONSEXCLUDEUSER USERNAME

FETCHOPTIONSNOUSESNAPSHOT

TRANLOGOPTIONS  CONVERTUCS2CLOBS

TABLEscott.dept;

TABLEscott.emp;

注意:threadsRAC節(jié)點(diǎn)數(shù)相同即可,RAC中不再使用ORACLE_SID設(shè)置,而使用USERID ogg@RAC,注意兩個(gè)節(jié)點(diǎn)均可連接數(shù)據(jù)庫。

添加傳輸進(jìn)程,配置參數(shù)

GGSCI(node1) 2> add extract dpend,exttrailsource ./dirdat/nd

EXTRACTadded.

GGSCI(node1) 3> add rmttrail /uo1/app/ogg/dirdat/nd, EXTRACT DPEND

RMTTRAILadded.

GGSCI(node1) 4> edit params dpend

(粘貼下面這段配置)

EXTRACTdpend

SETENV(NLS_LANG = AMERICAN_AMERICA.UTF8)

USERID ogg@RAC, PASSWORDoracle

PASSTHRU

RMTHOST10.123.112.235, MGRPORT 7839, compress

RMTTRAIL/uo1/app/ogg/dirdat/nd

TABLEscott.dept;

TABLEscott.emp;

3.7 配置目標(biāo)數(shù)據(jù)庫

目標(biāo)庫創(chuàng)建GoldenGate數(shù)據(jù)庫用戶并授權(quán):

createuser ogg identified by oracle default tablespace USERS;

grantconnect,resource,unlimited tablespace to ogg;

grantexecute on utl_file to ogg;

grantselect any dictionary,select any table to ogg;

grantalter any table to ogg;

grantflashback any table to ogg;

grantexecute on DBMS_FLASHBACK to ogg;

grantinsert any table to ogg;

grantdelete any table to ogg;

grantupdate any table to ogg;

添加checkpoint

GGSCI(sun.linux) 2> edit params GLOBALS

然后在參數(shù)文件中輸入

GGSCHEMAogg

CHECKPOINTTABLEogg.checkpoint

GGSCI(sun.linux) 4> dblogin userid ogg,password oracle

Successfullylogged into database.

GGSCI(sun.linux) 5> add checkpointtable ogg.checkpoint

Successfullycreated checkpoint table ogg.checkpoint.

3.8 配置目標(biāo)端進(jìn)程組

配置MGR參數(shù)

GGSCI(sun.linux) 6> edit params mgr

(粘貼下面這段配置)

PORT7839

DYNAMICPORTLIST7840-7939

--AUTOSTARTER *

AUTORESTARTEXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS./dirdat/*,usecheckpoints, minkeepdays 3

LAGREPORTHOURS1

LAGINFOMINUTES30

LAGCRITICALMINUTES45

配置復(fù)制隊(duì)列

GGSCI(sun.linux)8> add replicat repnd,exttrail/uo1/app/ogg/dirdat/nd,checkpointtable ogg.checkpoint

REPLICATadded.

GGSCI(sun.linux) 10> edit params repnd

(粘貼下面這段配置)

REPLICATrepnd

SETENV(NLS_LANG = AMERICAN_AMERICA.UTF8)

USERIDogg, PASSWORD oracle

ASSUMETARGETDEFS

REPERRORdefault,discard

discardfile./dirrpt/repnd.dsc,append,megabytes 50

mapscott.*,target pmsbi.*;

3.9 啟動(dòng)進(jìn)程進(jìn)行數(shù)據(jù)同步

啟動(dòng)源端進(jìn)程組

啟動(dòng)抽取進(jìn)程和傳輸進(jìn)程:

startextnd

startdpend

啟動(dòng)后使用info all查看進(jìn)程狀態(tài),正常status應(yīng)該RUNNING,顯示如下:

GGSCI(node1) 19> info all

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                         

EXTRACT     RUNNING    DPEND       00:00:00      00:00:09  

EXTRACT     RUNNING    EXTND       00:00:00      00:00:04

啟動(dòng)目標(biāo)端進(jìn)程

startrepnd

顯示如下:

GGSCI(sun.linux) 2> info all

Program     Status     Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                         

REPLICAT    RUNNING    REPND       00:00:00      00:00:03

到此RAC到單點(diǎn)OGG的安裝配置就完成了,可以進(jìn)行數(shù)據(jù)同步測試了。

4       RACà單機(jī)下的HA配置

    第4部分的RACà單機(jī)的配置僅僅完成了數(shù)據(jù)復(fù)制的功能,不包含高可用的配置,當(dāng)運(yùn)行GoldenGate的節(jié)點(diǎn)出現(xiàn)故障時(shí)復(fù)制功能就將終止,如何使復(fù)制功能繼續(xù)可用呢,有如下兩種方式:

4.1 節(jié)點(diǎn)故障的手工處理方式

因?yàn)镚oldenGate 安裝在共享目錄下,我們可以通過任一個(gè)節(jié)點(diǎn)連接到共享目錄,啟動(dòng)GoldenGate運(yùn)行界面。如果其中一個(gè)節(jié)點(diǎn)失敗,導(dǎo)致GoldenGate進(jìn)程中止,可以直接手工在另外一個(gè)節(jié)點(diǎn)啟動(dòng)進(jìn)程組即可。

4.2 GoldenGate的HA配置

我們可以通過使用CRS來管理GoldenGate資源組,并且使用RAC的vip連接到GoldenGate,一旦數(shù)據(jù)庫的某一個(gè)節(jié)點(diǎn)宕掉,Oracleclusterware將自動(dòng)切換到另一個(gè)可用節(jié)點(diǎn)。

添加一個(gè)應(yīng)用程序VIP資源

為GoldenGate vip資源創(chuàng)建一個(gè)profile

[oracle@node1ggate]$ cd $ORA_CRS_HOME/bin

[oracle@node1bin]$ pwd

/u01/app/oracle/product/10.2.0/crs_1/bin

[oracle@node1 bin]$crs_profile –create ggvip –t application \

–a /u01/app/oracle/product/10.2.0/crs_1\

-o oi=eth0,ov=192.168.73.203,on=255.255.255.0

其中:ggvip為創(chuàng)建的應(yīng)用程序vip的名字

把這個(gè)資源注冊到CRS:

[oracle@node1 bin]$crs_register ggvip

把vip 的所有權(quán)給root,在root用戶下執(zhí)行:

[root@node1 bin]#./crs_setperm ggvip –o root

為oracle用戶分配啟動(dòng)這個(gè)資源的權(quán)限:

[root@node1 bin]#./crs_setperm ggvip –u user:oracle:r-x

通過oracle用戶啟動(dòng)這個(gè)資源:

[oracle@node1bin]$ crs_start ggvip

Attempting tostart `ggvip` on member `node1`

Start of`ggvip` on member `node1` succeeded.

查看資源狀態(tài)顯示如下:

[oracle@node1bin]$ crs_stat ggvip -t

Name           Type           Target    State    Host       

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

ggvip          application    ONLINE   ONLINE    node1

創(chuàng)建一個(gè)action程序

action程序我們這里放到共享磁盤上,action程序最少需要可以接受三個(gè)參數(shù):start,stop,check

start和stop:返回0成功,1 失??;

check     :返回0表示GoldenGate在運(yùn)行,1 表示不運(yùn)行;

下面為示例程序 gg_action.scr的內(nèi)容:

#!/bin/sh

#set the OracleGoldengate installation directory

exportGGS_HOME=/ggate

#set the oraclehome to the database to ensure GoldenGate will get the

#rightenvironment settings to be able to connect to the database

exportORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

#specify delayafter start before checking for successful start

start_delay_secs=5

#Include theGoldenGate home in the library path to start GGSCI

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

#check_processvalidates that a manager process is running at the PID

#thatGoldenGate 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 exitsuccess

    exit 0

  else

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

  then

    #manager process is running on the PID exitsuccess

    exit 0

  else

    #manager process is not running on the PID

    exit 1

  fi

fi

else

  #manager is not running because there is noPID file

  exit 1

fi

}

#call_ggsci isa 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 thestart manager command

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

  sleep ${start_delay_secs}

  #check whether manager is running and exitaccordingly

  check_process

  ;;

'stop')

  #attempt a clean stop for all non-managerprocesses

  #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-managerprocesses

  #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

添加一個(gè)應(yīng)用程序profile

[oracle@node1 ggate]$cd $ORA_CRS_HOME/bin

[oracle@node1bin]$ pwd

/u01/app/oracle/product/10.2.0/crs_1/bin

[oracle@node1 bin]$crs_profile –create GG_app –t application \

–r ggvip –a/ggate/gg_action.scr –o ci=10

其中:-r ggvip表示ggvip必須在GoldenGate啟動(dòng)之前運(yùn)行,

-a /ggate/gg_action.scr指定action 腳本的位置,在每個(gè)節(jié)點(diǎn)必須都可用

–o ci=10:檢查的時(shí)間間隔設(shè)置為10

把這個(gè)資源注冊到CRS:

[oracle@node1 bin]$crs_register GG_app

把vip 的所有權(quán)給root,在root用戶下執(zhí)行:

[root@node1 bin]#./crs_setperm ggvip –o oracle

為oracle用戶分配啟動(dòng)這個(gè)資源的權(quán)限:

[root@node1 bin]#./crs_setperm GG_app –u user:oracle:r-x

通過oracle用戶啟動(dòng)這個(gè)資源:

[oracle@node1bin]$ crs_start GG_app

Attempting tostart `GG_app` on member `node1`

Start of`GG_app` on member `node1` succeeded.

查看資源狀態(tài)顯示如下:

[oracle@node1bin]$ crs_stat GG_app -t

Name           Type           Target    State     Host      

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

GG_app         application    ONLINE   ONLINE    node1 

測試節(jié)點(diǎn)遷移

在測試環(huán)境中可以使用crs_relocate –fGG_app使它強(qiáng)行漂移:過程顯示如下:

[oracle@node1~]$ crs_stat -t

Name           Type           Target    State    Host       

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

GG_app         application   ONLINE    ONLINE    node1     

ggvip           application   ONLINE    ONLINE    node1     

ora....AC1.srv    application   ONLINE    ONLINE    node1     

ora....AC2.srv    application   ONLINE    ONLINE    node2     

ora.RAC.RAC.cs application    ONLINE   ONLINE    node2      

ora....C1.inst    application   ONLINE    ONLINE    node1     

ora....C2.inst    application   ONLINE    ONLINE    node2     

ora.RAC.db     application    ONLINE   ONLINE    node1      

ora....E1.lsnr    application   ONLINE    ONLINE    node1     

ora.node1.gsd   application   ONLINE    ONLINE    node1     

ora.node1.ons   application   ONLINE    ONLINE    node1     

ora.node1.vip   application   ONLINE    ONLINE    node1     

ora....E2.lsnr    application   ONLINE    ONLINE    node2     

ora.node2.gsd   application   ONLINE    ONLINE    node2     

ora.node2.ons   application   ONLINE    ONLINE   node2      

ora.node2.vip   application   ONLINE    ONLINE    node2     

[oracle@node1 ~]$ crs_relocate -f GG_app

Attempting to stop `GG_app` on member `node1`

Stop of `GG_app` on member `node1` succeeded.

Attempting to stop `ggvip` on member `node1`

Stop of `ggvip` on member `node1` succeeded.

Attempting to start `ggvip` on member `node2`

Start of `ggvip` on member `node2` succeeded.

Attempting to start `GG_app` on member `node2`

Start of `GG_app` on member `node2` succeeded.

[oracle@node1~]$ crs_stat -t

Name           Type           Target    State    Host       

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

GG_app         application    ONLINE   ONLINE    node2      

ggvip           application    ONLINE   ONLINE    node2      

ora....AC1.srv    application   ONLINE    ONLINE    node1     

ora....AC2.srv    application   ONLINE    ONLINE    node2     

ora.RAC.RAC.cs  application   ONLINE    ONLINE    node2     

ora....C1.inst     application   ONLINE    ONLINE    node1     

ora....C2.inst     application   ONLINE    ONLINE    node2     

ora.RAC.db      application   ONLINE    ONLINE    node1     

ora....E1.lsnr     application   ONLINE    ONLINE    node1     

ora.node1.gsd    application   ONLINE    ONLINE   node1      

ora.node1.ons    application   ONLINE    ONLINE    node1     

ora.node1.vip    application   ONLINE    ONLINE    node1     

ora....E2.lsnr     application   ONLINE    ONLINE    node2     

ora.node2.gsd    application   ONLINE    ONLINE    node2     

ora.node2.ons    application   ONLINE    ONLINE    node2     

ora.node2.vip    application   ONLINE    ONLINE    node2     

可以看到GoldenGate成功轉(zhuǎn)移到2節(jié)點(diǎn)運(yùn)行了。

5       常見錯(cuò)誤及解決方法

5.1OGG-00446

啟動(dòng)源端抽取進(jìn)程extnd,ggserr.log錯(cuò)誤顯示如下:

2012-08-1711:11:38  ERROR   OGG-00446 Oracle GoldenGate Capture for Oracle, extnd.prm:  Could not find archived log for sequence45835 thread 1 under default destinations SQL <SELECT  name   FROM v$archived_log   WHEREsequence# = :ora_seq_no AND         thread#= :ora_thread AND         resetlogs_id =:ora_resetlog_id AND         archived ='YES' AND         deleted = 'NO' AND         name not like '+%'         AND standby_dest = 'NO' >, errorretrieving redo file name for sequence 45835, archived = 1, use_alternate =0Not able to establish initial position for begin time 2012-08-15 17:28:28.

導(dǎo)致原因:早期歸檔日志被刪除或已備份,導(dǎo)致找不到歸檔日志文件;

處理方法:

將備份的歸檔日志恢復(fù)到歸檔日志目錄下,即可解決錯(cuò)誤;

測試庫可以指定抽取進(jìn)程從某個(gè)時(shí)間點(diǎn)開始讀取日志,跳過已刪除的歸檔日志文件,命令如下:alterextract extnd,begin 2012-8-16 16:38;

5.2OGG-01223

啟動(dòng)源端傳輸進(jìn)程DPENDggserr.log錯(cuò)誤顯示如下:

2012-08-1711:43:50  WARNING OGG-01223  Oracle GoldenGate Capture for Oracle,dpend.prm:  TCP/IP error 79 (Connectionrefused).

2012-08-1711:45:01  WARNING OGG-01223  Oracle GoldenGate Capture for Oracle,dpend.prm:  TCP/IP error 79 (Connectionrefused).

導(dǎo)致原因:因?yàn)槟繕?biāo)端110MGR進(jìn)程沒有啟動(dòng),導(dǎo)致報(bào)錯(cuò)

處理方法:

在目標(biāo)端啟動(dòng)startmgr啟動(dòng)進(jìn)程后,再啟動(dòng)源端的傳輸進(jìn)程DPEND,錯(cuò)誤消失,文件順利傳輸過來了。

正常的日志如下:

2012-08-1714:31:51  INFO    OGG-00993 Oracle GoldenGate Capture for Oracle, dpend.prm:  EXTRACT DPEND started.

2012-08-1714:33:13  INFO    OGG-01226 Oracle GoldenGate Capture for Oracle, dpend.prm:  Socket buffer size set to 27985 (flush size27985).

2012-08-1714:33:26  INFO    OGG-01052 Oracle GoldenGate Capture for Oracle, dpend.prm:  No recovery is required for target file F:\ogg\dirdat\nd000000,at RBA 0 (file not opened).

2012-08-1714:33:26  INFO    OGG-01478 Oracle GoldenGate Capture for Oracle, dpend.prm:  Output file F:\ogg\dirdat\nd is using formatRELEASE 11.2.

5.3OGG-01224

啟動(dòng)源端傳輸進(jìn)程DPEND,ggserr.log錯(cuò)誤顯示如下:

2012-08-2205:33:10  ERROR   OGG-01224 Oracle GoldenGate Capture for Oracle, dpend.prm:  TCP/IP error 113 (No route to host).

2012-08-2205:33:10  ERROR   OGG-01668 Oracle GoldenGate Capture for Oracle, dpend.prm:  PROCESS ABENDING.

導(dǎo)致原因:因?yàn)槟繕?biāo)端235上的防火墻沒有關(guān)閉,導(dǎo)致報(bào)錯(cuò)

處理方法:

在目標(biāo)端機(jī)器關(guān)閉防火墻后,再啟動(dòng)源端的傳輸進(jìn)程DPEND,錯(cuò)誤消失,文件順利傳輸過來了。

5.4OGG-01031

啟動(dòng)源端傳輸進(jìn)程DPENDggserr.log錯(cuò)誤顯示如下:

2012-08-28 15:09:39  ERROR  OGG-01031  Oracle GoldenGateCapture for Oracle, dpend.prm:  There isa problem in network communication, a remote file problem, encryption keys fortarget and source do not match (if using ENCRYPT) or an unknown error. (Replyreceived is Unable to open file '/uo1/app/ogg/dirdat/nd000004' (error2, No such file or directory)).

2012-08-28 15:09:41  ERROR  OGG-01668  Oracle GoldenGateCapture for Oracle, dpend.prm:  PROCESSABENDING.目標(biāo)端ggserr.log錯(cuò)誤顯示如下:

2012-08-2815:06:30  WARNING OGG-01223  Oracle GoldenGate Collector for Oracle:  Unable to lock file'/uo1/app/ogg/dirdat/nd000004' (error 11, Resource temporarilyunavailable).  Lock currently held byprocess id (PID) 13854.

2012-08-2815:06:30  WARNING OGG-01223  Oracle GoldenGate Collector for Oracle:  Unable to open file'/uo1/app/ogg/dirdat/nd000004' (error 2, No such file or directory).

導(dǎo)致原因:可能是網(wǎng)絡(luò)出現(xiàn)過故障,OGG源端的Data Pump進(jìn)程與目標(biāo)斷了聯(lián)系,目標(biāo)端mgr為其啟動(dòng)的server進(jìn)程一直還在運(yùn)行,下次data pump重啟時(shí)目標(biāo)mgr會(huì)試圖生成另外一個(gè)server進(jìn)程,這樣兩個(gè)進(jìn)程會(huì)爭同一個(gè)隊(duì)列文件。

處理方法:

1、停掉源端的所有data pump,使用ps –ef|grep server(或OGG安裝目錄)看看是不是還有OGG的server進(jìn)程在跑,如果有,殺死它(一定要確認(rèn)源端data pump全停掉,并且殺的是server進(jìn)程,不要?dú)⑵渌黣xtract/replicat/mgr等),重啟源端data pump即可。

2、可能是目標(biāo)端的trail file出問題了,前滾重新生成一個(gè)新的隊(duì)列文件

SEND EXTRACT xxx ETROLLOVER

或者:alter extract xxx etrollover

xxx為datapump的名稱

5.5OGG-01154

錯(cuò)誤信息:2011-03-29 15:53:57  WARNINGOGG-01154  Oracle GoldenGate Delivery forOracle, repya.prm:  SQL error 14402mapping EPMA.D_METER to E

PMA.D_METER OCIError ORA-14402: updating partition key column would cause a partition change(status = 14402), SQL <UPDATE 'EPMA'.'D_METER' SET'PR_ORG' = :a1,'BELONG_DEPT' = :a2 WHERE'METER_ID' = :b0>.

導(dǎo)致原因:源端更新了分區(qū)列,但目標(biāo)端沒有打開行移動(dòng),導(dǎo)致更新時(shí)報(bào)錯(cuò);

處理方法:SQLPLUS>alter table SCHEMA.TABLENAME enable row movement;

參考文章:http://blog.csdn.net/huashnag/article/details/13505939

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多