ALTER DATASBASE ARCHIVELOG;
开启强制日志
ALTER DATABASE FORCE LOGGING;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
修改参数
ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION=TRUE;
创建用户
--创建用户表空间
create tablespace ogg datafile '/u01/app/oracle/oradata/ogg.dbf' size 2G autoextend off;
--创建用户
create user ogg identified by ogg default tablespace ogg;
--添加权限
grant connect,resource,create session,alter session,select any dictionary,select any table,flashback any table,alter any table,insert any table,update any table,delete any table,select any transaction,execute on DBMS_CAPTURE_ADM to ogg;
解压安装
GGSCI>edit params mgr
port 7809
DYNAMICPORTLIST 7840-7850
PURGEOLDEXTRACTS /u01/ogg/testogg/dirdat/*,usecheckpoints,minkeepdays 7
创建defgen文件
a.编辑defgen参数
GGSCI> edit params defgen
defsfile /u01/ogg/dirdef/sync.def
userid ogg,password ogg?123
table DC_DC.DC_RA_MER_BASE;
b.生成defgen文件
./defgen paramfile /oraogg/app/dirprm/defgen.prm
c.将sync.def复制到目标端dirdef目录下
添加表附加日志
GGSCI>add trandata DC_DC.DC_RA_MER_BASE;
配置抽取进程
a.创建trail文件目录
mkdir -p /u01/ogg/dirdat/EXMSSQL
b.添加抽取进程
GGSCI>add extract extest01,tranlog,threads 1,begin now
GGSCI>add exttrail /u01/ogg/dirdat/EXMSSQL/EX,extract extest01,megabytes 200
GGSCI>edit param extest01
extract extest01
SETENV(NLS_LANG="AMERICAN_AMERICA.AL32UTF8")
SETENV(ORACLE_SID="source")
USERID ogg,PASSWORD ogg
TRANLOGOPTIONS DBLOGREADER
TRANLOGOPTIONS DBLOGREADER LOGRETENTION ENABLED
warnlongtrans 4h,checkinterval 10m
EXTTRAIL /u01/ogg/dirdat/EXMSSQL/EX
GETTRUNCATES
table DC_DC.DC_RA_MER_BASE;
配置投递进程
GGSCI >add extract putest01,EXTTRAILSOURCE /u01/ogg/dirdat/EXMSSQL/EX
GGSCI >add rmttrail R:\ogg\dirdat\REMSSQL\RE,ext putest01,megabytes 200
GGSCI >edit param PUMSSQL
extract PUMSSQL
USERID ogg, PASSWORD ogg?123
SETENV (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")
SETENV (ORACLE_SID = "source")
rmthost 182.168.8.1, mgrport 7809
rmttrail F:\OGG\dirdat\REMSSQL\RE
PASSTHRU
table DC_DC.DC_RA_MER_BASE;
配置ODBC接口
创建服务
>INSTALL ADDSERVICE
编辑GLOBALS
GGSCI >edit param ./GLOBALS
checkpointtable dbo.ckpttab
创建checkpoint表
GGSCI >dblogin lu userid sa password abcd123#
GGSCI >add checkpointtable dbo.ckpttab
配置MGR进程
GGSCI >edit params mgr
port 7809
DYNAMICPORTLIST 7840-7850
ACCESSRULE, PROG SERVER, ALLOW
autorestart er *, retries 5, waitminutes 3
purgeoldextracts F:\OGG\dirdat\*,usecheckpoints, minkeepdays 7
配置复制进程
a. 创建trail存放目录
F:\ogg\dirdat\REMSSQL
b.添加复制进程
GGSCI >add replicat REMSSQL,exttrail F:\OGG\dirdat\REMSSQL\RE,begin now,checkpointtable dbo.ckpttab
GGSCI >edit param REMSSQL
replicat REMSSQL
sourcedefs F:\OGG\dirdef\sync.def
targetdb lu userid sa, password abcd123#
reperror default,discard
discardfile F:\OGG\dirrpt\REMSSQL.dsc,append,megabytes 100
gettruncates
map DC_DC.DC_RA_MER_BASE,target dbo.DC_RA_MER_BASE;
初始化数据
a.在SQLSERVER创建相应表
b.源端导出相应表初始化数据
GGSCI> edit param exinit
SOURCEISTABLE
userid ogg, password ogg?123
rmthost 182.168.8.1, mgrport 7809
RMTFILE F:\OGG\dirdat\REMSSQL\EX,MAXFILES 1024, MEGABYTES 1024
table test.dc_ra_mer_base;
--OGG INSTALL DIRECTORY
$ ./extract paramfile ./dirprm/exinit.prm reportfile ./dirrpt/exinit.rpt
c.启动源端进程
GGSCI>start *
d.目标段导入相应初始化数据并启动进程
replicat paramfile ./dirprm/reinit.prm
GGSCI>start *