配置ogg异构oracle-mysql(2)源端配置

源端配置大致分为如下三个步骤:配置mgr,配置抽取进程,配置投递进程

在源端先创建一张表,记得带主键:

SQL> create table ah4(id int ,name varchar(10),primary key(id));

Table created.

1.登陆ogg,配置全局设置

[oracle@ora11g 11.2]$ ./ggsci 

Oracle GoldenGate Command Interpreter for Oracle
Version   OGGCORE_11..3_PLATFORMS_120823.1258_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Aug   ::

Copyright (C) , , Oracle and/or its affiliates. All rights reserved.

GGSCI (ora11g) > dblogin userid ggs password ggs
Successfully logged into database.

GGSCI (ora11g) 2> view params ./globals

ggschema ggs

 

2.配置mgr

GGSCI (ora11g) 3>  edit param mgr

PORT 7809
DYNAMICPORTLIST 7810-7909
--AUTOSTART ER *
AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 3
PURGEOLDEXTRACTS ./dirdat/*,usecheckpoints, minkeepdays 3
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45

PS:

MANAGER进程参数配置说明:
PORT:指定服务监听端口;这里以7809为例,默认端口为7809
DYNAMICPORTLIST:动态端口:可以制定最大256个可用端口的动态列表,当指定的端口不可用时,管理进程将会从列表中选择一个可用的端口,源端和目标段的Collector、Replicat、GGSCI进程通信也会使用这些端口;
COMMENT:注释行,也可以用--来代替;
AUTOSTART:指定在管理进程启动时自动启动哪些进程;
AUTORESTART:自动重启参数设置:本处设置表示每3分钟尝试重新启动所有EXTRACT进程,共尝试5次;
PURGEOLDEXTRACTS:定期清理trail文件设置:本处设置表示对于超过3天的trail文件进行删除。
LAGREPORT、LAGINFO、LAGCRITICAL:
定义数据延迟的预警机制:本处设置表示MGR进程每隔1小时检查EXTRACT的延迟情况,如果超过了30分钟就把延迟作为信息记录到错误日志中,如果延迟超过了45分钟,则把它作为警告写到错误日志中。

3.启动mgr,并查看状态

GGSCI (ora11g) 6> start mgr

Manager started.

GGSCI (ora11g) 7> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING    

4.添加并查看需要复制的表:

GGSCI (ora11g) 8> add trandata hr.ah4

Logging of supplemental redo data enabled for table HR.AH4.

GGSCI (ora11g) 9> info trandata hr.*

Logging of supplemental redo log data is enabled for table HR.AH1.

Columns supplementally logged for table HR.AH1: ID.

Logging of supplemental redo log data is enabled for table HR.AH2.

Columns supplementally logged for table HR.AH2: ID.

Logging of supplemental redo log data is enabled for table HR.AH3.

Columns supplementally logged for table HR.AH3: ID.

Logging of supplemental redo log data is enabled for table HR.AH4.

Columns supplementally logged for table HR.AH4: ID.

Logging of supplemental redo log data is disabled for table HR.COUNTRIES.

Logging of supplemental redo log data is disabled for table HR.DEPARTMENTS.

Logging of supplemental redo log data is disabled for table HR.EMPLOYEES.

Logging of supplemental redo log data is disabled for table HR.JOBS.

Logging of supplemental redo log data is disabled for table HR.JOB_HISTORY.

Logging of supplemental redo log data is disabled for table HR.LOCATIONS.

Logging of supplemental redo log data is disabled for table HR.REGIONS.

Logging of supplemental redo log data is disabled for table HR.SURE1.

GGSCI (ora11g) 10> 

5.配置抽取进程

GGSCI (ora11g) 11> edit params ext3

extract ext3
dynamicresolution
userid ggs,password ggs
exttrail /u01/ogg/11.2/dirdat/xs
table hr.ah4;
--table hr.ah5;
GGSCI (ora11g) 13> add extract ext3,tranlog,begin now
EXTRACT added.

GGSCI (ora11g) 14> add exttrail /u01/ogg/11.2/dirdat/xs,extract ext3
EXTTRAIL added.

GGSCI (ora11g) 15> 

PS:

ext的模板可以是:

EXTRACT extmb
setenv (NLS_LANG = "AMERICAN_AMERICA.UTF8")
SETENV (ORACLE_HOME = "/u01/oracle/product/11.2.0/db_1")
SETENV (ORACLE_SID = "orcl")
USERID ggs, PASSWORD ggs
--GETTRUNCATES
REPORTCOUNT EVERY 1 MINUTES, RATE
DISCARDFILE ./dirrpt/extmb.dsc,APPEND,MEGABYTES 1024
--THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 60000 IOLATENS 60000
DBOPTIONS ALLOWUNUSEDCOLUMN
WARNLONGTRANS 2h,CHECKINTERVAL 3m
EXTTRAIL ./dirdat/mb
--TRANLOGOPTIONS EXCLUDEUSER USERNAME
FETCHOPTIONS NOUSESNAPSHOT
TRANLOGOPTIONS CONVERTUCS2CLOBS
TABLE hr.emp;

SETENV:配置系统环境变量
USERID/ PASSWORD: 指定OGG连接数据库的用户名和密码,这里使用3.4部分中创建的数据库用户OGG;
COMMENT:注释行,也可以用--来代替;
TABLE:定义需复制的表,后面需以;结尾
TABLEEXCLUDE:定义需要排除的表,如果在TABLE参数中使用了通配符,可以使用该参数指定排除掉得表。
GETUPDATEAFTERS|IGNOREUPDATEAFTERS:
是否在队列中写入后影像,缺省复制
GETUPDATEBEFORES| IGNOREUPDATEBEFORES:
是否在队列中写入前影像,缺省不复制
GETUPDATES|IGNOREUPDATES:
是否复制UPDATE操作,缺省复制
GETDELETES|IGNOREDELETES:
是否复制DELETE操作,缺省复制
GETINSERTS|IGNOREINSERTS:
是否复制INSERT操作,缺省复制
GETTRUNCATES|IGNORETRUNDATES:
是否复制TRUNCATE操作,缺省不复制;

6.配置投递进程

GGSCI (ora11g) 17> edit params push3 

extract push3
passthru
dynamicresolution
userid ggs,password ggs
rmthost 192.168.0.166,mgrport 7809
rmttrail /u01/ogg/11.2/dirdat/xs
table hr.ah4;
GGSCI (ora11g) 18> add extract push3,exttrailsource /u01/ogg/11.2/dirdat/xs
EXTRACT added.

GGSCI (ora11g) 19> add rmttrail /u01/ogg/11.2/dirdat/xs,extract push3
RMTTRAIL added.

GGSCI (ora11g) 20> 

PS:

push的模板:

EXTRACT pushmb
SETENV (NLS_LANG = "AMERICAN_AMERICA.UTF8")
USERID ggs, PASSWORD ggs
PASSTHRU
RMTHOST 192.168.0.165, MGRPORT 7809, compress
RMTTRAIL /u01/ogg/11.2/dirdat/xs
TABLE hr.ah4;

RMTHOST:指定目标系统及其Goldengate Manager进程的端口号,还用于定义是否使用压缩进行传输,本例中的compress为压缩传输;
RMTTRAIL:指定写入到目标断的哪个队列;
EXTTRAIL:指定写入到本地的哪个队列;
SQLEXEC:在extract进程运行时首先运行一个SQL语句;
PASSTHRU:禁止extract进程与数据库交互,适用于Data Pump传输进程;
REPORT:定义自动定时报告;
STATOPTIONS:定义每次使用stat时统计数字是否需要重置;
REPORTCOUNT:报告已经处理的记录条数统计数字;
TLTRACE:打开对于数据库日志的跟踪日志;
DISCARDFILE:定义discardfile文件位置,如果处理中油记录出错会写入到此文件中;
DBOPTIONS:指定对于某种特定数据库所需要的特殊参数;
TRANLOGOPTIONS:指定在解析数据库日志时所需要的特殊参数,例如:对于裸设备,可能需要加入以下参数 rawdeviceoggset 0
WARNLONGTRANS:指定对于超过一定时间的长交易可以在gsserr.log里面写入警告信息,本处配置为每隔3分钟检查一次场交易,对于超过2小时的进行警告;

7.配置define文件

因为是异构,所以define作为2个数据库之间表的关系映射,是必不可少的。

GGSCI (ora11g) 21> edit params ah4

defsfile /u01/ogg/11.2/dirdef/ah4.prm
userid ggs,password ggs
table hr.ah4;

去相应的目录下生产define文件:

[oracle@ora11g 11.2]$ ./defgen paramfile dirprm/ah4.prm                 

***********************************************************************
        Oracle GoldenGate Table Definition Generator for Oracle
 Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258
   Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 16:58:29

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

                    Starting at 2014-04-02 15:47:20
***********************************************************************

Operating System Version:
Linux
Version #1 SMP Fri Jan 27 17:17:51 EST 2012, Release 2.6.18-308.el5
Node: ora11g
Machine: x86_64
                         soft limit   hard limit
Address Space Size   :    unlimited    unlimited
Heap Size            :    unlimited    unlimited
File Size            :    unlimited    unlimited
CPU Time             :    unlimited    unlimited

Process id: 31345

***********************************************************************
**            Running with the following parameters                  **
***********************************************************************
defsfile /u01/ogg/11.2/dirdef/ah4.prm
userid ggs,password ***
table hr.ah4;
Retrieving definition for HR.AH4

Definitions generated for 1 table in /u01/ogg/11.2/dirdef/ah4.prm

[oracle@ora11g 11.2]$ 

并将生成的/u01/ogg/11.2/dirdef/ah4.prm 传到目的端的相应目录中去

[root@ora11g ~]#  scp /u01/ogg/11.2/dirdef/ah4.prm 192.168.0.166:/u01/ogg/11.2/
Display all 108 possibilities? (y or n)
[root@ora11g ~]#  scp /u01/ogg/11.2/dirdef/ah4.prm 192.168.0.166:/u01/ogg/11.2/dirdef/
The authenticity of host '192.168.0.166 (192.168.0.166)' can't be established.
RSA key fingerprint is 67:c6:bb:27:ba:70:17:31:00:5b:4e:39:3c:fd:92:ad.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.166' (RSA) to the list of known hosts.
root@192.168.0.166's password:
ah4.prm                                                                                           100%  991     1.0KB/s   00:00
[root@ora11g ~]# 

至此,源端就配置完毕了。

上一篇:转战物联网·基础篇07-深入理解MQTT协议之控制报文(数据包)格式


下一篇:VC中Source Files, Header Files, Resource Files,External Dependencies的区别