zoukankan      html  css  js  c++  java
  • 阿里yugong配置使用

    介绍:yugong中文意思叫愚公移山,是阿里为解决单机oralce无法满足扩展性问题,同时为了去IOE,实现oracle数据迁移到mysql上。

       java语言开发,所以需要java语言平台

       yugong是通过收集物化视图日志实现数据的迁移

       yugong有6中运行模式(MARK开启增量记录模式、FULL全量模式、INC增量模式、ALL全量+增量模式、CHECK数据对比模式、CLEAR清理增量记录模式)

       数据迁移过程:

      

       本文是在ubuntu系统上安装配置

       官方文档:https://github.com/alibaba/yugong/

    前期准备:

       1.安装jdk

        apt-get install openjdk-8-jdk

       2.下载解压

        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.创建数据表

    #源数据表
    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=user #源数据库用户名
    yugong.database.source.password=123  #源数据库用户密码
    yugong.database.source.type=ORACLE 
    yugong.database.source.url=jdbc:oracle:thin:@127.0.0.1:1521/oradbtest  #jdbc:oracle:thin:@ip:端口/服务名
    yugong.database.source.encode=UTF-8
    yugong.database.source.poolSize=30
    
    yugong.database.target.url=jdbc:mysql://127.0.0.1:3306/groupcrm
    yugong.database.target.username=user
    yugong.database.target.password=123
    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

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

       

    验证全量:

       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`

       

    验证增量:

       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`

        

     查看日志:

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

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

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

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

    停止服务:

       sh bin/stop.sh

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

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

  • 相关阅读:
    Foundations of Machine Learning: The PAC Learning Framework(2)
    Foundations of Machine Learning: The PAC Learning Framework(1)
    图形渲染流水线
    如何用python的装饰器定义一个像C++一样的强类型函数
    Python 装饰器学习心得
    PAT 1087 All Roads Lead to Rome
    PAT 1086 Tree Traversals Again
    PAT 1085 Perfect Sequence
    PAT 1084 Broken Keyboard
    LeetCode: Sort Colors
  • 原文地址:https://www.cnblogs.com/shier-dong/p/13563619.html
Copyright © 2011-2022 走看看