环境:
源端:192.168.133.136
目标端:192.168.133.137
数据库版本:11.2.0.4
ogg 版本:18.1
操作系统:centos 7.6
目标:
使用 ogg进行数据初始化
好处和坏处,大家见百度。
过程:
1.源目两边 数据准备 (源端和目标端)
sql>conn / as sysdba
sql>create user sztech identified by sztech;
sql>grant connect,resource to sztech;
sql>conn sztech/sztech
sql>
CREATE TABLE dept(
DEPTNO NUMBER(4),
DNAME VARCHAR2(14),
LOC VARCHAR2(13)
);
--源端插入数据(下面数据插入只在源端操作,目标端通过ogg同步过程)
INSERT INTO dept_ogg VALUES (10,'ACCOUNTING','NEW YORK');
INSERT INTO dept_ogg VALUES (20,'RESEARCH','DALLAS');
INSERT INTO dept_ogg VALUES (30,'SALES','CHICAGO');
INSERT INTO dept_ogg VALUES (40,'OPERATIONS','BOSTON');
2.源目两边创建复制用户 ogg
sql>create user ogg identified by ogg;
sql>grant dba to ogg;
3.源目两边配置 ogg
3.1 源目两边安装 ogg 18.1
具体安装过程略。
3.2 修改源目两边数据库参数
alter system set enable_goldengate_replication=true;
3.3 进入ogg安装位置
cd $OGG_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
./ggsci
3.4 配置mgr
源端:
GGSCI (dbserver) 7> edit params mgr
port 7809
目标端:
GGSCI (server2 as ogg@orcl) 66> view param mgr
port 7809
ACCESSRULE, PROG *, IPADDR 192.168.133.136, ALLOW
3.5 源端配置初始抽取进程
GGSCI (dbserver) 20> add extract eini_1,sourceistable
EXTRACT added.
GGSCI (dbserver) 25> EDIT PARAMS EINI_1
EXTRACT EINI_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ogg
RMTHOST 192.168.131.1, MGRPORT 7809
RMTTASK REPLICAT, GROUP RINI_1
TABLE sztech.DEPT;
3.6 目标端配置初始复制进程
GGSCI ((server2 as ogg@orcl)) 8> edit params rini_1
REPLICAT RINI_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
ASSUMETARGETDEFS
USERID ogg, PASSWORD ogg
DISCARDFILE ./dirrpt/RINIaa.dsc, PURGE
MAP sztech.*, TARGET sztech.*;
GGSCI ((server2 as ogg@orcl)) 14> add replicat RINI_1,specialrun
4.开始同步
GGSCI (dbserver) 8> start eini_1
5.数据验证
源端和目标端都有以下数据:
SQL> select * from dept_ogg;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
后面初始抽取进程eini_1和初始复制进程rini_1会自动停止。
|