Install Goldengate On Oracle Rac 11.2.0.4,goldengate11.2.0.4
安裝環境:
source:OS:redhat 6.3DB:11.2.0.4 racOGG:11.2.1.0.1target:OS:redhat 6.3DB:11.2.0.4OGG:11.2.1.0.1
rac到單機的一個傳輸配置,這裡測試ogg沒有放入到共用儲存中。建議生產環境將ogg放入共用儲存,以免單點故障。
Prepare(Source And Target DB):
useradd ogg -g oinstallAdd Environment Variblevi /home/oracle/.bash_profileexport LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/oggConfigure Databasealter database archivelog;alter database force logging;alter database add supplemental log data;For Oracle DB versions 11.2.0.4 and 12.1.0.2 there will be a new init.ora parameter called ENABLE_GOLDENGATE_REPLICATION. In order for some of the Oracle GoldenGate functionality to work, this parameter must be set to true.ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;Create OGG User:sqlplus / as sysdbacreate user ogg identified by ogg;grant dba to ogg;GGSCI (zbdba1) 1> edit params ./GLOBALGGSCHEMA oggCHECKPOINTTABLE ogg.checkpointInstalling the DDL objects:1、Run the @marker_setup.sql script. This script installs support for the Oracle GoldenGatemarker system, which is required for DDL support. You will be prompted for the nameof the Oracle GoldenGate schema.2、Run the @ddl_setup.sql script Script that installs the Oracle GoldenGate DDL extraction andreplication objects. (Oracle installations)3、Run the @role_setup.sql script. This script drops and creates the role needed for DDLsynchronization. It grants DML permissions on the Oracle GoldenGate DDL objects4、Grant the role to all Oracle GoldenGate Extract users. You may need to make multiplegrants if the processes have different user names.Run the @ddl_enable.sql script to enable the DDL trigger.5、To improve the performance of the DDL trigger, make the ddl_pin script part of the databasestartup. It must be invoked with the Oracle GoldenGate DDL user name, as in:@?/rdbms/admin/dbmspool.sqlSQL> @ddl_pin oggTo improve the performance of the DDL trigger This script pins the PL/SQL package that is used by the trigger into memory. If executingthis script from SQL*Plus, connect as SYSDBA from the Oracle GoldenGate home directory.This script relies on the Oracle dmbs_shared_pool system package, so install that packagebefore using ddl_pin.
Source DB:
MANAGERGGSCI (zbdba1) 1> create subdirsGGSCI (zbdba1) 22> view param mgrport 7839DYNAMICPORTLIST 7840-7914USERID OGG,PASSWORD oggAUTORESTART EXTRACT *, RETRIES 5, WAITMINUTES 3PURGEOLDEXTRACTS ./DIRDAT/*,MINKEEPDAYS 3PURGEDDLHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10,FREQUENCYMINUTES 30PURGEMARKERHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10LAGREPORTHOURS 1LAGINFOMINUTES 30LAGCRITICALMINUTES 45
<pre name="code" class="html">GGSCI (zbdba1) 3> dblogin userid ogg,password ogg;Successfully logged into database.GGSCI (zbdba1) 1> add trandata zbdba.*
EXTRACTadd extract ext1,tranlog, threads 2, begin nowadd exttrail /ogg/dirdat/sa extract ext1add rmttrail ./dirdat/sa,extract ext1
這裡使用asm時候,需要強調一下, Oracle 10.2.0.5、Oracle 11.2.0.2 版本和後續版本的資料庫中,Oracle 提供了一個新的 ASM API介面 ,可以讓 extract 進程直接利用資料庫伺服器來訪問 redo 和 archive log。使用該 API 後,extract 將獲得一個最大不超過 4 mb 的read buffer。read buffer 越大,對於 redo 量較高的 環境越容易提高 Extract 的進程。可以通過使用 TRANLOGOPTIONS 的 DBLOGREADERBUFSIZE 選項來指定read buffer 的大小。
這種方案只需要在抽取進程的參數中加:
TRANLOGOPTIONS DBLOGREADER
其他版本的方案:
指明asm使用者密碼和歸檔路徑
TRANLOGOPTIONS ASMUSER sys@asm1, ASMPASSWORD oracleTRANLOGOPTIONS ALTARCHIVELOGDEST primary instance test1 /opt/oracle/arch, ALTARCHIVELOGDEST primary instance test2 /opt/oracle/arch
配置tnsnames.ora
ASM1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.52)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = +ASM) (INSTANCE_NAME= +ASM1) ) )
並且兩個節點的歸檔需要用nfs映射。
這裡資料庫版本是11.2.0.4,所以採用方案一
EXTRACT EXT1setenv ( NLS_LANG = AMERICAN_AMERICA.ZHS16GBK )setenv (ORACLE_SID= "test1")USERID ogg,PASSWORD oggTRANLOGOPTIONS DBLOGREADERDDL &INCLUDE MAPPED OBJTYPE 'TABLE' &INCLUDE MAPPED OBJTYPE 'IDNEX' &INCLUDE MAPPED OBJTYPE 'SEQUENCE' &INCLUDE MAPPED OBJTYPE 'VIEW' &INCLUDE MAPPED OBJTYPE 'PROCEDURE' &INCLUDE MAPPED OBJTYPE 'FUNCTION' &INCLUDE MAPPED OBJTYPE 'PACKAGE' &INCLUDE MAPPED OBJTYPE 'MATERIALIZED VIEW' &EXCLUDE OPTYPE COMMENTDDLOPTIONS ADDTRANDATA NOCROSSRENAME REPORTREPORTCOUNT EVERY 1 MINUTES,RATEDISCARDFILE ./dirrpt/EXTSA.DSC,APPEND,MEGABYTES 1024THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 60000 IOLATENCY 60000DBOPTIONS ALLOWUNUSEDCOLUMNWARNLONGTRANS 2H,CHECKINTERVAL 3Mexttrail ./dirdat/saFETCHOPTIONS NOUSESNAPSHOT,FETCHPKUPDATECOLS,MISSINGROW REPORTtable zbdba.*;
datapumpGGSCI (zbdba1) 4>> add extract ext2,exttrailsource /ogg/dirdat/saEXTRACT added. ADD EXTTRAIL ./dirdat/sa, EXTRACT EXT2GGGSCI (zbdba1) 4> add rmttrail /ogg/dirdat/sa, extract ext2RMTTRAIL added.GGSCI (zbdba1) 2> view param ext2EXTRACT EXT2passthruRMTHOST 192.168.56.61,MGRPORT 7839,COMPRESSRMTTRAIL ./dirdat/satable zbdba.*;
Target DB:
GGSCI (zbdba2) 1> create subdirsGGSCI (zbdba2) 42> view param mgrport 7839DYNAMICPORTLIST 7840-7914USERID OGG,PASSWORD oggAUTORESTART REPLICAT *, RETRIES 5, WAITMINUTES 3PURGEOLDEXTRACTS ./dirdat/*,MINKEEPDAYS 3PURGEDDLHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10,FREQUENCYMINUTES 30PURGEMARKERHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10LAGREPORTHOURS 1LAGINFOMINUTES 30LAGCRITICALMINUTES 45 Create Replicat GGSCI (zbdba2) 1> view param ./GLOBALSGGSCHEMA oggCHECKPOINTTABLE ogg.checkpointGGSCI (zbdba2) 1> dblogin userid ogg,password oggGGSCI (zbdba2) 2> add checkpointtable ogg.checkpointSuccessfully created checkpoint table OGG.CHECKPOINT.GGSCI (zbdba2) 2> add replicat rep1,exttrail /ogg/dirdat/sa, checkpointtable ogg.checkpointREPLICAT added.GGSCI (zbdba2) 19> edit param rep1REPLICAT rep1ASSUMETARGETDEFSUSERID ogg, PASSWORD oggdiscardfile ./dirdat/rep1_discard.txt,append,megabytes 5DDL INCLUDE MAPPEDDDLOPTIONS REPORTBATCHSQLDBOPTIONS DEFERREFCONSTDBOPTIONS LOBWRITESIZE 102400HANDLECOLLISIONSDDLERROR DEFAULT DISCARD RETRYOP MAXRETRIES 5 RETRYDELAY 20--grouptransops 1--maxtransops 1APPLYNOOPUPDATESMAP zbdba.*, TARGET zbdba.*;start managerGGSCI (zbdba2) 23> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNING REPLICAT STOPPED REP1 00:00:00 00:00:03
Test Data(Source and Target DB):
create tablepsace zbdab datafile '/opt/oracle/oradata/zbdba.dbf' size 100m;create zbdba identified by oracle default tablespace zbdba;grant dba to zbbda;On Source DB:User data pump:expdp zbdba/oracle DIRECTORY=dumpdir DUMPFILE=zbdba.dmp LOGFILE=zbdba.log SCHEMAS=zbdba JOB_NAME=exp_zbdba_schemascp data to target DBOn Target DB:impdp zbdba/oracle DIRECTORY=dumpdir DUMPFILE=zbdba.dmp SCHEMAS=zbdba JOB_NAME=imp_zbdba_schema GGSCI (ogg2) 24> start rep1Sending START request to MANAGER ...REPLICAT REP1 startingGGSCI (ogg2) 26> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNING REPLICAT RUNNING REP1 00:00:00 00:00:07 On Source DB:create table test as select * from dba_objects;Monitor OGG(Source And Target DB):tail -100f ggserr.log