---- OGG19.1 配置集成捕獲Extract進程、pump和replicat進程
---- Configuring the Primary Extract in Integrated Capture Mode
-- 20200716
-- Configuring the Primary Extract in Integrated Capture Mode
-- Basic parameters for Extract mining a non-mulitenant database
--- 本文源數據庫和downstream數據庫為同一個;源數據庫和目標數據庫的配置權限參看《OGG19.1 oracle12c到oracle12c經典模式配置實施 》
--- 源數據庫 需 設置streams_pool_size: alter system set streams_pool_size = 1024M scope=spfile; --實時生效
----0.將primary extract in Integrated Capture Mode 注冊進logminer server DB
------前提 在源庫配置完成 用戶 OGG 及其權限等
GGSCI > dblogin userid ogg@oggsdb password Password123
GGSCI (dbserver as ogg@oggsdb) 3> register extract exint database ---- 關鍵點1 :否則報錯:Logmining server does not exist on this Oracle database
---1. source db: Primary Extract in Integrated Capture Mode
添加一個extract in Integrated Capture Mode進程 :
GGSCI > add extract exint,integrated tranlog,begin now ----, threads 2 ---- 關鍵點2 integrated tranlog:否則為 classic mode extract
GGSCI > edit params exint
添加以下內容
extract exint
setenv (ORACLE_SID = "OGGSDB")
setenv (NLS_LANG = "AMERICAN_AMERICA.AL32UTF8")
userid ogg@oggsdb, password Password123
--TRANLOGOPTIONS MININGUSERALIAS alias --downstream mining database streams_pool_size
TRANLOGOPTIONS INTEGRATEDPARAMS(parallelism 2)
TRANLOGOPTIONS GETCTASDML
DDL INCLUDE MAPPED
exttrail /oradata/ogg/dirdat/oggsdb/ei
discardfile /oradata/ogg/dirdat/exint.dsc, append, megabytes 100
getupdatebefores
nocompressdeletes
nocompressupdates
--LOGALLSUPCOLS
dboptions allowunusedcolumn
fetchoptions nousesnapshot
fetchoptions fetchpkupdatecols
table SCOTT.EMP;
table SCOTT.DEPT;
創建本地trail文件 :
GGSCI > add exttrail /oradata/ogg/dirdat/oggsdb/ei, extract exint
EXTTRAIL added.
--ADD EXTTRAIL/RMTTRAIL /oradata/ogg/dirdat/oggsdb/ei, EXTRACT EXINT
--2. source db: Pump Extract in Integrated Capture Mode
添加一個pump進程(本質上也是extract進程),並指定遠程trail文件:
GGSCI > add extract exppint,exttrailsource /oradata/ogg/dirdat/oggsdb/ei
EXTRACT added.
編輯pump參數文件:
GGSCI (dbserver) 16> edit params exppint
添加以下內容
EXTRACT exppint
passthru
rmthost 192.168.6.20, mgrport 7809 ---- target db主機ip,管理進程端口號 ##共用同一台主機的mgr進程 測試
rmttrail /oradata/ogg/dirdat/oggtdb/pi
table SCOTT.EMP;
table SCOTT.DEPT;
指定遠程trail文件:
GGSCI > add rmttrail /oradata/ogg/dirdat/oggtdb/pi, extract exppint
RMTTRAIL added.
--3. target db:replicat 進程
--3.1 配置 target db : ogg用戶及權限
--3.2 配置 target db 端 MGR進程(共用)
--3.3 添加checkpoint表
GGSCI> edit params ./GLOBALS
添加以下內容
ggschema ogg
checkpointtable ogg.checkpoint
登陸target db添加checkpoint表
export ORACLE_SID=OGGTDB
./ggsci
GGSCI > dblogin userid ogg@OGGTDB, password Password123
Successfully logged into database.
GGSCI (dbserver as ogg@OGGTDB) > add checkpointtable ogg.checkpoint
--3.4 增加配置 replicat 進程
GGSCI (dbserver as ogg@oggtdb) 4> add replicat repint, INTEGRATED, exttrail /oradata/ogg/dirdat/oggtdb/pi ----關鍵點:INTEGRATED 關鍵字
----ADD REPLICAT repint, INTEGRATED, EXTTRAIL /oradata/ogg/dirdat/oggtdb/pi
----alter REPLICAT repint, INTEGRATED
----ALTER REPLICAT group, EXTSEQNO seqno, EXTRBA RBA
---- 多個replicat進程
----這兩個新的參數文件與原有的參數文件的主要區別是將其中的復制表按負載均分為了兩部分,分別放在單獨的參數文件中。
----GGSCI> dblogin userid 用戶名, password 密碼
----GGSCI> ADD REPLICAT rgs_cx2,EXTTRAIL ./dirdat/cg checkpointtable gsgg_checkpoint
----GGSCI> ADD REPLICAT rgs_cx3,EXTTRAIL ./dirdat/cg checkpointtable gsgg_checkpoint
----GGSCI> info rgs_cx1,showch
----GGSCI> alter rgs_cx2, extseqno
----GGSCI> alter rgs_cx3, extseqno
編輯replicat參數文件:
GGSCI (dbserver as ogg@oggtdb) 6> edit params repint
添加以下內容
replicat repint
setenv (ORACLE_SID = "OGGTDB")
setenv (NLS_LANG = "AMERICAN_AMERICA.AL32UTF8")
userid ogg@oggtdb, password Password123
dboptions deferrefconst
gettruncates
report at 06:00
reportcount every 30 minutes, rate
reportrollover at 02:00
--reperror default, abend
REPERROR DEFAULT,DISCARD
DBOPTIONS NOSUPPRESSTRIGGERS
--handlecollisions
allownoopupdates
--assumetargetdefs
discardfile /oradata/ogg/dirdat/oggtdb/repint.dsc, append, megabytes 100
discardrollover at 02:00
--map scott.emp, target scott.emp;
map scott.dept, target scott.dept;
--3.5 啟動 MGR 、Extract、Pump 和 REPLICAT 進程。
GGSCI > info all
GGSCI > start exint
GGSCI > start exppint
GGSCI > start repint
--3.6 測試和排錯troubleshooting。
--Monitoring and Controlling Processing After the Instantiation
STATS REPLICAT repint
select * from V$GG_APPLY_RECEIVER;
select * from V$GOLDENGATE_TABLE_STATS
- 源庫和目標庫的數據同步測試驗證
最后,可如下測試驗證:
源庫執行,再源庫和備份同時驗證變更同步。
select * from scott.dept;
-- inert data
insert into scott.dept(deptno,dname,LOC) values(50,'HEADQUARTERS','WUHAN');
commit;
-- add table column and modify data
alter table scott.dept add(comment1 varchar2(30));
alter table scott.dept add(comment2 varchar2(30));
alter table scott.dept drop(comment2);
alter table scott.dept add(comment2 varchar2(30));
update scott.dept set comment2='YYY' where deptno=10;
commit;
alter table scott.dept drop(comment2);
update scott.dept set comment1='AAAAA' where deptno=50;
commit;
update scott.dept set comment1='AAA' where deptno=50;
commit;
-- update key value
update scott.dept set deptno=60 where deptno=50;
commit;
insert into scott.dept(deptno,dname,LOC) values(70,'HR','WUHAN-GUANGGU');
commit;
--- delete data
delete from scott.dept where deptno=70;
commit;
