阿里yugong(愚公)linux配置使用教程

安装Java JDK

yum install java-1.8.0-openjdk* -y

1.jpg

安装完成后输入java,测试是否安装成功

2.jpg

下载yugong,并解压

wget https://github.com/alibaba/yugong/releases/download/yugong-1.0.3/yugong-1.0.3.tar.gz
tar -zxvf yugong-1.0.3.tar.gz -C /usr/local/yugong

3.jpg

创建数据表

#源数据表
create table yugong_example_oracle
 (   
     id NUMBER(11)  ,
     name varchar2(32) ,
     alias_name  char(32) default ' ' not null,
     amount number(11,2),
     score  number(20), 
     text_b blob,
     text_c clob,
     gmt_create date not null,
     gmt_modified date not null,     
     CONSTRAINT yugong_example_oracle_pk_id  PRIMARY   KEY (id) 
 );
#目标数据表
create table yugong_example_mysql
 (   
     id bigint(20) unsigned auto_increment,
     display_name varchar(128) ,
     amount varchar(32),
     score bigint(20) unsigned , 
     text_b blob,
     text_c text,
     gmt_create timestamp not null,
     gmt_modified timestamp not null,
     gmt_move timestamp not null,     
     CONSTRAINT yugong_example_mysql_pk_id  PRIMARY KEY (id) 
 );

修改配置

cd /usr/local/yugong/
vim conf/yugong.properties
yugong.database.source.username=test
yugong.database.source.password=test
yugong.database.source.type=ORACLE
yugong.database.source.url=jdbc:oracle:thin:@127.0.0.1:1521/test
yugong.database.source.encode=UTF-8
yugong.database.source.poolSize=30

yugong.database.target.url=jdbc:mysql://127.0.0.1:3306/test
yugong.database.target.username=test 
yugong.database.target.password=test
yugong.database.target.type=DRDS
yugong.database.target.encode=UTF-8
yugong.database.target.poolSize=30

yugong.table.white=yugong_example_oracle  #需要同步的表

vim conf/translator/YugongExampleOracleDataTranslator.java(文件名中YugongExampleOracle是源表名)

record.setTableName("yugong_example_mysql");    #yugong_example_mysql为目标表

启动: 

sh bin/startup.sh

1.jpg

oracle库中会增加如下两个表,临时表和物化视图日志表

2107594-20200828094539637-284626899.png

这两个表千万不用删除,删除后不会再创建

验证全量:

1.源库yugong_example_oracle表中插入两条数据    

insert into yugong_example_oracle values(1,'ljh','agapple',10.2,100, NULL , NULL ,sysdate,sysdate);
insert into yugong_example_oracle values(2,'yugong','yugong',16.88,2088, NULL , NULL ,sysdate,sysdate);

2.查看目标库yugong_example_mysql表中是否有相同数据   

SELECT * FROM `yugong_example_mysql`

2.jpg

验证增量:

1.源库yugong_example_oracle表中插入1条和修改1条数据

insert into yugong_example_oracle values(3,'test','test',88,188, NULL , NULL ,sysdate,sysdate) ;
update yugong_example_oracle set alias_name = 'superman' where id = 1;

2.查看目标库yugong_example_mysql表中是否有相同数据

SELECT * FROM `yugong_example_mysql`

3.jpg 

3. 查看日志:

查看系统日志:cat logs/table.log

查看表日志:vim logs/YUGONG_EXAMPLE_ORACLE/table.log

查看提取数据日志:vim logs/YUGONG_EXAMPLE_ORACLE/extractor.log

查看更新到目标日志:vim logs/YUGONG_EXAMPLE_ORACLE/applier.log

停止服务:

sh bin/stop.sh

4.jpg

注意:在未执行停止命令stop.sh前不要关机,否则再次启动或停止会出现意想不到的情况发生。

 特别注意:假如目标表同步完一段时间后将目标表数据清空重新同步,需要将yucong/conf/positioner/目录下对应的以表命名的dat文件删除,否则会出现再次同步失败情况。

修改配置

正常情况下,只需修改下yugong.database的源库和目标库的地址信息,通过yugong.table.white定义本次需要迁移的表,通过yugong.table.mode定义要执行的操作,是全量还是增量等,其他的可以使用默认值.

默认值    :


有问题请联系作者QQ:4505399(备注:vb盒子)
打赏
« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。