程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> Install Goldengate On Oracle Rac 11.2.0.4

Install Goldengate On Oracle Rac 11.2.0.4

編輯:Oracle教程

Install Goldengate On Oracle Rac 11.2.0.4


安裝環境:

 

source:
OS:redhat 6.3
DB:11.2.0.4 rac
OGG:11.2.1.0.1

target:
OS:redhat 6.3
DB:11.2.0.4
OGG:11.2.1.0.1

rac到單機的一個傳輸配置,這裡測試ogg沒有放入到共享存儲中。建議生產環境將ogg放入共享存儲,以免單點故障。


Prepare(Source And Target DB):

useradd ogg -g oinstall

Add Environment Varible
vi /home/oracle/.bash_profile
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/ogg

Configure Database
alter 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 sysdba
create user ogg identified by ogg;
grant dba to ogg;


GGSCI (zbdba1) 1> edit params ./GLOBAL
GGSCHEMA ogg
CHECKPOINTTABLE ogg.checkpoint

Installing the DDL objects:
1、Run the @marker_setup.sql script. This script installs support for the Oracle GoldenGate
marker system, which is required for DDL support. You will be prompted for the name
of the Oracle GoldenGate schema.
2、Run the @ddl_setup.sql script   Script that installs the Oracle GoldenGate DDL extraction and
replication objects. (Oracle installations)
3、Run the @role_setup.sql script. This script drops and creates the role needed for DDL
synchronization. It grants DML permissions on the Oracle GoldenGate DDL objects
4、Grant the role to all Oracle GoldenGate Extract users. You may need to make multiple
grants 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 database
startup. It must be invoked with the Oracle GoldenGate DDL user name, as in:
@?/rdbms/admin/dbmspool.sql
SQL> @ddl_pin ogg
To improve the performance of the DDL trigger 
This script pins the PL/SQL package that is used by the trigger into memory. If executing
this 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 package
before using ddl_pin.

 

Source DB:

 

MANAGER
GGSCI (zbdba1) 1>  create subdirs

GGSCI (zbdba1) 22> view param mgr

port 7839
DYNAMICPORTLIST 7840-7914
USERID OGG,PASSWORD ogg
AUTORESTART EXTRACT *, RETRIES 5, WAITMINUTES 3
PURGEOLDEXTRACTS ./DIRDAT/*,MINKEEPDAYS 3
PURGEDDLHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10,FREQUENCYMINUTES 30
PURGEMARKERHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45

EXTRACT
add extract ext1,tranlog, threads 2, begin now
add exttrail /ogg/dirdat/sa  extract ext1
add 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 oracle
TRANLOGOPTIONS 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 EXT1
setenv ( NLS_LANG = AMERICAN_AMERICA.ZHS16GBK )
setenv (ORACLE_SID= "test1")
USERID ogg,PASSWORD ogg
TRANLOGOPTIONS DBLOGREADER
DDL &
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 COMMENT
DDLOPTIONS ADDTRANDATA NOCROSSRENAME REPORT
REPORTCOUNT EVERY 1 MINUTES,RATE
DISCARDFILE ./dirrpt/EXTSA.DSC,APPEND,MEGABYTES 1024
THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 60000 IOLATENCY 60000
DBOPTIONS ALLOWUNUSEDCOLUMN
WARNLONGTRANS 2H,CHECKINTERVAL 3M
exttrail ./dirdat/sa
FETCHOPTIONS NOUSESNAPSHOT,FETCHPKUPDATECOLS,MISSINGROW REPORT
table zbdba.*;

datapump
GGSCI (zbdba1) 4>> add extract ext2,exttrailsource /ogg/dirdat/sa
EXTRACT added.

 ADD EXTTRAIL ./dirdat/sa, EXTRACT EXT2

GGGSCI (zbdba1) 4> add rmttrail  /ogg/dirdat/sa, extract ext2
RMTTRAIL added.


GGSCI (zbdba1) 2>  view param ext2

EXTRACT EXT2
passthru
RMTHOST 192.168.56.61,MGRPORT 7839,COMPRESS
RMTTRAIL ./dirdat/sa
table zbdba.*;

Target DB:

 

 

GGSCI (zbdba2) 1>  create subdirs

GGSCI (zbdba2) 42> view param mgr

port 7839
DYNAMICPORTLIST 7840-7914
USERID OGG,PASSWORD ogg
AUTORESTART REPLICAT *, RETRIES 5, WAITMINUTES 3
PURGEOLDEXTRACTS ./dirdat/*,MINKEEPDAYS 3
PURGEDDLHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10,FREQUENCYMINUTES 30
PURGEMARKERHISTORY MINKEEPDAYS 7,MAXKEEPDAYS 10
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45 


Create Replicat 
GGSCI (zbdba2) 1>  view param ./GLOBALS
GGSCHEMA ogg
CHECKPOINTTABLE ogg.checkpoint
GGSCI (zbdba2) 1> dblogin userid ogg,password ogg
GGSCI (zbdba2) 2> add checkpointtable  ogg.checkpoint

Successfully created checkpoint table OGG.CHECKPOINT.

GGSCI (zbdba2) 2>  add replicat rep1,exttrail /ogg/dirdat/sa, checkpointtable ogg.checkpoint
REPLICAT added.


GGSCI (zbdba2) 19> edit param rep1

REPLICAT rep1
ASSUMETARGETDEFS
USERID ogg, PASSWORD ogg
discardfile ./dirdat/rep1_discard.txt,append,megabytes 5
DDL INCLUDE MAPPED
DDLOPTIONS REPORT
BATCHSQL
DBOPTIONS DEFERREFCONST
DBOPTIONS LOBWRITESIZE 102400
HANDLECOLLISIONS
DDLERROR DEFAULT DISCARD RETRYOP MAXRETRIES 5 RETRYDELAY 20
--grouptransops 1
--maxtransops 1
APPLYNOOPUPDATES
MAP zbdba.*, TARGET zbdba.*;


start manager


GGSCI (zbdba2) 23> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     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_schema


scp data to target DB


On Target DB:
impdp zbdba/oracle DIRECTORY=dumpdir
           DUMPFILE=zbdba.dmp SCHEMAS=zbdba
           JOB_NAME=imp_zbdba_schema 


GGSCI (ogg2) 24> start rep1

Sending START request to MANAGER ...
REPLICAT REP1 starting

GGSCI (ogg2) 26> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     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 





 


 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved