此文已由作者赵欣授权网易云社区发布。
欢迎访问网易云社区,了解更多网易技术产品运营经验。
自从oracle收购来了goldengate这款产品并以后对它做了一系列改进后,有非常多的用户使用它做数据迁移、etl抽取、复制容灾等等场景。
create user oggtest identified by oracle;
grant connect,resource to oggtest;
select supplemental_log_data_min from v$database;
alter database add supplemental log data;
select force_logging from v$database;
Alter database force logging;
alter database add supplemental log data (primary key,unique,foreign key) columns;
create user goldengate identified by oracle;
grant resource, connect, dba to goldengate;
mkdir trails
./ggsci
CREATE SUBDIRS
edit param mgr
Port 7809
userid goldengate , password oracle
DYNAMICPORTLIST 9101-9356
ADD EXTRACT t1,TRANLOG, EXTSEQNO 746, EXTRBA 0
edit param t1
extract t1
USERID goldengate, PASSWORD oracle
DISCARDFILE t1dsc,APPEND,MEGABYTES 50
TRANLOGOPTIONS altarchivelogdest /home/oracle/arch
TRANLOGOPTIONS ARCHIVEDLOGONLY
TRANLOGOPTIONS NOCOMPLETEARCHIVEDLOGONLY
FORMATSQL
EXTTRAIL ./trails/t1
TABLE oggtest.*;
ADD EXTTRAIL ./trails/t1 EXTRACT T1
create table oggtest.ogg(a int constraint key1 primary key,b varchar2(100),c varchar2(100),d date default sysdate);
insert into oggtest.ogg(a,b,c,d) values(1,1,1,sysdate);
insert into oggtest.ogg(a,b,c,d) values(2,2,2,sysdate);
insert into oggtest.ogg(a,b,c,d) values(3,3,3,sysdate);
commit;
insert into oggtest.ogg(a,b,c,d) values(4,4,4,sysdate);
insert into oggtest.ogg(a,b,c,d) values(5,5,5,sysdate);
commit;
update oggtest.ogg set b=2 where a=5;
commit;
B,2015-02-24:14:53:05.000000,1424760785,749,
INSERT INTO OGGTEST.OGG (A,B,C,D) VALUES ('1','1','1','2015-02-24:14:53:05');
INSERT INTO OGGTEST.OGG (A,B,C,D) VALUES ('2','2','2','2015-02-24:14:53:05');
INSERT INTO OGGTEST.OGG (A,B,C,D) VALUES ('3','3','3','2015-02-24:14:53:05');
C,
B,2015-02-24:14:53:06.000000,1424760786,749,
INSERT INTO OGGTEST.OGG (A,B,C,D) VALUES ('4','4','4','2015-02-24:14:53:05');
INSERT INTO OGGTEST.OGG (A,B,C,D) VALUES ('5','5','5','2015-02-24:14:53:05');
C,
B,2015-02-24:14:53:49.000000,1424760829,750,
UPDATE OGGTEST.OGG SET B='2' WHERE A='5';
C,
B,2015-02-24:15:04:45.000000,1424761485,755,
INSERT INTO OGG2.TEST2015 (A,B,C,D) VALUES ('1','1','1','2015-02-24:15:04:45');
C,
B,2015-02-24:15:04:46.000000,1424761486,755,
UPDATE OGG2.TEST2015 SET B='2' WHERE A='1';
create table oggtest.ogg2(a int constraint key2 primary key,b varchar2(100),c varchar2(100),d date default sysdate);
dblogin userid goldengate, password oracle
add trandata oggtest.ogg2, cols(b,c,d)
insert into oggtest.ogg2(a,b,c,d) values(8,8,8,sysdate);
insert into oggtest.ogg2(a,b,c,d) values(9,9,9,sysdate);
insert into oggtest.ogg(a,b,c,d) values(1,1,1,sysdate);
commit;
update oggtest.ogg2 set b=9 where a=8;
commit;
[oracle@oel5 dirout]$ more pump_OGGTEST_OGG2_2015-02-24_21-41-25_00000_data.dsv.temp
I|8|8|8|2015-02-24:21:41:19
I|9|9|9|2015-02-24:21:41:19
U|8|9|8|2015-02-24:21:41:19
[oracle@oel5 dirout]$ more pump_OGGTEST_OGG_2015-02-24_21-41-25_00001_data.dsv.temp
I|1|1|1|2015-02-24:21:41:19
免费领取验证码、内容安全、短信发送、直播点播体验包及云服务器等套餐
更多网易技术、产品、运营经验分享请点击。