过程:
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
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