Oracle ...

OGG Oracle 源端部署文档 (实时同步 + DDL 同步

2019-04-01  本文已影响2人  fordZrx
1. 配置前准备:

(1)安装ogg
(2)Oracle 数据库配置
(3)创建 ogg 管理账号(dba权限)
以上内容请参考:在Windows中 基于Oracle GoldenGate (OGG)进行Oracle->Oracle数据库同步配置(超详细)

1. 开始安装:
E:\ogg\oggTest> ggsci.exe
Oracle GoldenGate Command Interpreter for Oracle
Version 12.2.0.2.3 OGGCORE_12.2.0.2.0_PLATFORMS_170727.1430
Windows x64 (optimized), Oracle 11g on Jul 27 2017 16:38:50
Operating system character set identified as GBK.

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

(1) 注册 ogg 服务

GGSCI> edit params ./GLOBALS

MGRSERVNAME GGMGR_TEST
GGSCHEMA ggs
_DISABLEFIX21427144

MGRSERVNAME:ogg服务名
GGSCHEMA:ogg 管理账号

E:\ogg\oggTest>install addservice
Service 'GGMGR_TEST' created.
Install program terminated normally.

(2) 配置基础功能

E:\ogg\oggTest> ggsci.exe
// 创建文件夹
GGSCI> create subdirs
// 登陆数据库 dblogin userid ogg账号,password ogg密码
GGSCI> dblogin userid ggs,password ggs
// 添加表级的trandata,add trandata 同步数据库名.*
GGSCI> add trandata XZMIS.*

(3)配置MGR

GGS> edit params mgr

添加以下配置

port 7900
dynamicportlist 7901-7905
AUTOSTART EXTRACT *
AUTORESTART EXTRACT *,RETRIES 5, WAITMINUTES 2, RESETMINUTES 20
AUTORESTART ER , RETRIES 10, WAITMINUTES 2, RESETMINUTES 60
LAGREPORTHOURS 1
LAGINFOMINUTES 5
LAGCRITICALMINUTES 7
PURGEOLDEXTRACTS E:\ogg\oggTest\dirdat*, USECHECKPOINTS, MINKEEPDAYS 10
ACCESSRULE, PROG , IPADDR ...
, ALLOW

port:mgr默认端口号
dynamicportlist:当默认端口不可用使用的备用端口
PURGEOLDEXTRACTS ogg安装目录\dirdat\*, USECHECKPOINTS, MINKEEPDAYS 10

// 启动mgr
GGS> start mgr

(4)开启 DDL 同步:

// 停止ogg进程
GGS> stop mgr
// Ctrl + c 退出 ggsci ,从ogg目录进入oracle
E:\ogg\oggTest>sqlplus "/as sysdba"
// 开启 DDL 需要 ogg 账号拥有单独的表空间,创建表空间
SQL> create tablespace ogg_data datafile 'E:\oracle_bf\ogg_1.dbf' size 640M autoextend on next 80M maxsize unlimited;
// 更改ogg账号表空间
SQL> alter user ggs default tablespace ogg_data;
// 赋予用户utl_file权限
SQL> grant execute on utl_file to ggs;
SQL> @marker_setup.sql
SQL> @ddl_setup.sql
SQL> @role_setup.sql
SQL> grant ggs_ggsuser_role to ggs;
SQL> @ddl_enable.sql
SQL> @?/rdbms/admin/dbmspool.sql
SQL> @ddl_pin.sql ggs
// 查询 NLS_LANG
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')
--------------------------------------------------------------------------------
SIMPLIFIED AMERICAN_AMERICA.AL32UTF8

注意:执行 @marker_setup.sql@ddl_setup.sql 脚本时根据提示输入 ogg账号
例:

SQL>  @marker_setup.sql

Marker setup script

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:ggs


Marker setup table script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to GGS

MARKER TABLE
--------------------------------------------------------------
OK

MARKER SEQUENCE
--------------------------------------------------------------
OK

Script complete.

(5)配置抽取进程

//  Ctrl + c 退出 sqlplus,运行 ggsci.exe
E:\ogg\oggTest> ggsci.exe
// 启动mgr
GGSCI> start mgr
GGSCI> edit params eora

添加以下配置

extract eora
setenv (NLS_LANG="AMERICAN_AMERICA.AL32UTF8")
ddl include all
DDLOPTIONS ADDTRANDATA, REPORT
userid ggs,password ggs
exttrail E:\ogg\oggTest\dirdat\et
dynamicresolution
table XZMIS.*;

setenv (NLS_LANG=oracle NLS_LANG)
userid ogg账号,password ogg密码
exttrail ogg 安装目录\dirdat\et
table 数据库名.*

// 设置开始同步的时间
GGSCI> add extract eora,tranlog,begin now
// 此处路径为源端ogg安装路径:`ogg 安装目录\dirdat\et`
GGSCI> add exttrail E:\ogg\oggTest\dirdat\et,extract eora
// 启动 eora
GGSCI> start eora

add extract eora,tranlog,begin now //从当前时间开始同步
add extract eora, tranlog,begin 2019-02-11 13:00:00 //指定时间点开始同步

(6)配置投递进程

GGSCI> edit params pump_so

添加以下配置

extract Pump_so
Userid ggs,password ggs
rmthost 172.21.114.104, mgrport 7900
rmttrail F:\OGG\oggoracle\dirdat\et
dynamicresolution
Table XZMIS.*;

userid ogg账号,password ogg密码
rmthost 目标端 IP, mgrport 目标端mgr端口号
rmttrail 目标端 ogg 安装目录\dirdat\et
table 数据库名.*

// 注意`exttrailsource`的地址为`源端`服务器的目录
GGSCI> add extract pump_so,exttrailsource E:\ogg\oggTest\dirdat\et
// 注意`rmttrail`的地址为`目标端`服务器的目录
GGSCI> add rmttrail F:\OGG\oggoracle\dirdat\et,extract pump_so

(7)等待目标端 repl 进程启动后启动 源端进程

GGSCI > start mgr
GGSCI > start eora
GGSCI > start pump_so

正常情况下,启动 mgr 进程,其它两个进程会自动启动

GGSCI > info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EORA        00:00:00      00:00:08
EXTRACT     RUNNING     PUMP_SO     00:00:00      00:00:05

如有启动失败的进程,可查看错误日志文件:E:\ogg\oggTest\ggserr.log

上一篇下一篇

猜你喜欢

热点阅读