签到成功

知道了

CNDBA社区CNDBA社区

YuGong ORACLE 迁移 MYSQL (单表同步多表)

2018-04-23 16:39 5246 0 原创 数据库迁移
作者: Marvinn

YuGong ORACLE 迁移 MYSQL (单表同步多表)

注意:刚开始接触单表同步多表,按某个字段做映射,以为是做数据分片分割,原来实际是相当于,再目标库中复制了三张同数据内容,但不同表名以及单个映射字段不同的数据表.... 有点醉.... 

整个大概流程:

源库单表挑选字段 >>> 自定义数据转换文件配置,映射字段名,并可指定存放数据库名,不制定为默认同源库SCHEMA >>> 验证数据

YUGONG前期其他准备工作,参考文章链接:www.cndba.cn/Marvinn/article/2737,这里步骤直接跳过,直入主题开始参数配置文件,以及DataTranslator得配置,以及源端与目标端的表的创建

http://www.cndba.cn/Marvinn/article/2747

注意:当前环境之前的单表对单表以及多表合并单表迁移是仍然存在且在运行的,我并没有去除,也正好可以看看,各种需求放一起的配置

http://www.cndba.cn/Marvinn/article/2747

参数文件配置,沿用之前的配置,只需更改参数白名单即可。至于MYSQL数据库的选择,自行定

http://www.cndba.cn/Marvinn/article/2747

yugong.database.source.username=yugong
yugong.database.source.password=yugong
yugong.database.source.type=ORACLE
yugong.database.source.url=jdbc:oracle:thin:@//172.41.176.122:1521/orcl
yugong.database.source.encode=UTF-8
yugong.database.source.poolSize=30

yugong.database.target.url=jdbc:mysql://172.41.176.114:3306/test
yugong.database.target.url=jdbc:mysql://172.41.176.114:3306/marvin      可以指定一张表对应一个数据库mysql数据库
yugong.database.target.username=yugong
yugong.database.target.password=yugong
yugong.database.target.type=MYSQL
yugong.database.target.encode=UTF-8
yugong.database.target.poolSize=30

yugong.table.white=marvin.oracle1,scott.oracle2,marvin.marvin_join,scott.join_name,marvin.marvin_two                 --迁移表
yugong.table.mode=ALL
yugong.extractor.dump=true                             --这里DUMP出捕获日志,以便查看源端是否正常捕获数据,默认是false
yugong.applier.dump=true                               --这里DUMP出应用日志,以便查看目标端是否应用成功,默认false

yugong.table.concurrent.size=10                        -- 若有多张表处理,修改并发处理表数...默认值为5

新建DataTranslator文件(自定义数据转换)

http://www.cndba.cn/Marvinn/article/2747
http://www.cndba.cn/Marvinn/article/2747

注意:单表同步多表,DataTranslator命名是根据单表某个字段来做映射,其他字段都跟源表相同

所以,这里命名为MarvinTwoDataTranslator.java,另外,mysql对应表名为marvin_two_1以及marvin_two_2、marvin_two_3,当然,后续迁移完,表名、字段名、数据类型更改都是可以的…但是,如果想OGG一样,做数据实时同步,就不能更改了(有能力改改源码,应该也是可以实现的)http://www.cndba.cn/Marvinn/article/2747

[yugong@rac2 translator]$ cp YugongExampleTwoDataTranslator.java MarvinTwoDataTranslator.java
这里需copy成主连接的表的名字MarvinJoinDataTranslator,至于为什么,参考之前文章 单表对单表迁移文章

根据模版文件配置下哈,这里全部去掉示例,以便真实了解如何配置
[yugong@rac2 translator]$ cat MarvinTwoDataTranslator.java 
package com.taobao.yugong.translator;

import java.util.Arrays;
import java.util.List;

import com.google.common.collect.Lists;
import com.taobao.yugong.common.db.meta.ColumnValue;
import com.taobao.yugong.common.model.record.Record;

public class MarvinTwoDataTranslator extends AbstractDataTranslator implements DataTranslator {

    @Override
    public List<Record> translator(List<Record> records) {
        List<Record> result = Lists.newArrayListWithCapacity(records.size());
        for (Record record : records) {
            result.addAll(translatorOne(record));
        }

        return result;
    }

    public List<Record> translatorOne(Record record) {
        Record record1 = record;
        Record record2 = record.clone();

        record1.setTableName("marvin_two_1");       // 目标端同步表名1
        // 1. 字段名字不同
        ColumnValue name1Column = record.getColumnByName("name");     // 源端单表字段
        if (name1Column != null) {
            name1Column.getColumn().setName("name_1");        //目标端同步表变更字段
        }

        record2.setTableName("marvin_two_2");
        // 1. 字段名字不同
        ColumnValue name2Column = record2.getColumnByName("name");
        if (name2Column != null) {
            name2Column.getColumn().setName("name_2");
        }

        record3.setTableName("marvin_two_3");
        // 1. 字段名字不同
        ColumnValue name3Column = record3.getColumnByName("name");
        if (name3Column != null) {
            name3Column.getColumn().setName("name_3");
        }
        return Arrays.asList(record1, record2, record3);
    }

}

根据上面配置要求以及说明,创建测试表数据,其实正常逻辑是根绝表字段配置相关参数配置文件,但我这里出于搞清实际到底怎么配置,进行了逻辑反推,来验证….,验证成功,以后就可以根据我对配置文件DataTranslator的注释,进行需求配置环境了..

创建测试表数据http://www.cndba.cn/Marvinn/article/2747http://www.cndba.cn/Marvinn/article/2747

1. 源库有一张表:marvin_two
2. 目标库三张表:marvin_two_1,marvin_two_2以及marvin_two——3,每张表都和marvin_two存在一个字段名不同,name字段分别映射到name_1,name_2以及name_3,并且存放于不同的数据库中

测试的表结构:
oralce: 
create table marvin.marvin_two
(   
id NUMBER(11)  ,
name  varchar(32) default ' ' not null,
CONSTRAINT marvin_two_pk_id  PRIMARY   KEY (id) 
);

mysql:
create table test.marvin_two_1
(   
id bigint(20) unsigned auto_increment,
name_1 varchar(32) ,
CONSTRAINT marvin_two_1_pk_id  PRIMARY KEY (id) 
);


create table marvin.marvin_two_2
(   
id bigint(20) unsigned auto_increment,
name_2 varchar(32) ,
CONSTRAINT marvin_two_2_pk_id  PRIMARY KEY (id) 
 );

 create table marvin.marvin_two_3
(   
id bigint(20) unsigned auto_increment,
name_3 varchar(32) ,
CONSTRAINT marvin_two_3_pk_id  PRIMARY KEY (id) 
 );

源端插入测试数据:
declare
    i number;
begin
for i in 1..100000 loop
    insert into marvin.marvin_two values(i,'marvinn');
end loop;
    commit;
end;
/

简化配置文件一句话:就是目标端除下需要映射的拆分字段名以及约束名可不同于源端表之外,其他所有字段需相同

重新启动

yugong@rac2:/yugong/bin>sh stop.sh
yugong@rac2:/yugong/bin>sh start.sh

查看全局日志:
[yugong@rac2 yugong]$ tail -f table.log 

发现之前的单表对单表以及多表合并单表正常,刚配的同步表表异常
2018-04-23 14:16:27.536 [main] ERROR com.taobao.yugong.YuGongLauncher - ## Something goes wrong when starting up the YuGong:
com.taobao.yugong.exception.YuGongException: com.taobao.yugong.exception.YuGongException: source:com.taobao.yugong.translator.MarvinTwoDataTranslator, [MarvinTwoDataTranslator.java:40: error: cannot find symbol
        record3.setTableName("marvin_two_3");
        ^
  symbol:   variable record3
  location: class com.taobao.yugong.translator.MarvinTwoDataTranslator, MarvinTwoDataTranslator.java:42: error: cannot find symbol
        ColumnValue name3Column = record3.getColumnByName("name");
 是我自己添加的同步映射字段,报错... 报错原因,是由于不能发现record3的链接,再次查看并修改配置文件...
 [yugong@rac2 translator]$vi MarvinTwoDataTranslator.java 
package com.taobao.yugong.translator;

import java.util.Arrays;
import java.util.List;

import com.google.common.collect.Lists;
import com.taobao.yugong.common.db.meta.ColumnValue;
import com.taobao.yugong.common.model.record.Record;

public class MarvinTwoDataTranslator extends AbstractDataTranslator implements DataTranslator {

    @Override
    public List<Record> translator(List<Record> records) {
        List<Record> result = Lists.newArrayListWithCapacity(records.size());
        for (Record record : records) {
            result.addAll(translatorOne(record));
        }

        return result;
    }

    public List<Record> translatorOne(Record record) {
        Record record1 = record;
        Record record2 = record.clone();
        Record record3 = record.clone();             // 需要给新增的同步映射字段,克隆一个记录Record模板,否则报如上错误,无法链接

        record1.setTableName("marvin_two_1");       // 目标端同步表名1
        // 1. 字段名字不同
        ColumnValue name1Column = record.getColumnByName("name");     // 源端单表同步字段
        if (name1Column != null) {
            name1Column.getColumn().setName("name_1");        //目标端同步表变更字段
        }

        record2.setTableName("marvin_two_2");
        // 1. 字段名字不同
        ColumnValue name2Column = record2.getColumnByName("name");
        if (name2Column != null) {
            name2Column.getColumn().setName("name_2");
        }

        record3.setTableName("marvin_two_3");
        // 1. 字段名字不同
        ColumnValue name3Column = record3.getColumnByName("name");
        if (name3Column != null) {
            name3Column.getColumn().setName("name_3");
        }
        return Arrays.asList(record1, record2, record3);
    }

}

再次查看全局日志,发现仍然有报错(SCOTT.JOIN_NAME异常可忽略,具体原因请看多表合并迁移):
2018-04-23 14:21:09.989 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.controller.YuGongInstance - table[MARVIN.MARVIN_TWO] is error , current status:NORMAL !
2018-04-23 14:22:06.501 [pool-2-thread-2] INFO  com.taobao.yugong.common.stats.ProgressTracer - {未启动:0,全量中:0,增量中:0,已追上:3,异常数:2}
2018-04-23 14:22:06.501 [pool-2-thread-2] INFO  com.taobao.yugong.common.stats.ProgressTracer - 异常数:[MARVIN.MARVIN_TWO, SCOTT.JOIN_NAME]
2018-04-23 14:22:06.501 [pool-2-thread-2] INFO  com.taobao.yugong.common.stats.ProgressTracer - 已完成:[MARVIN.ORACLE1, SCOTT.ORACLE2, MARVIN.MARVIN_JOIN]
2018-04-23 14:23:06.502 [pool-2-thread-2] INFO  com.taobao.yugong.common.stats.ProgressTracer - {未启动:0,全量中:0,增量中:0,已追上:3,异常数:2}
2018-04-23 14:23:06.502 [pool-2-thread-2] INFO  com.taobao.yugong.common.stats.ProgressTracer - 异常数:[MARVIN.MARVIN_TWO, SCOTT.JOIN_NAME]
2018-04-23 14:23:06.502 [pool-2-thread-2] INFO  com.taobao.yugong.common.stats.ProgressTracer - 已完成:[MARVIN.ORACLE1, SCOTT.ORACLE2, MARVIN.MARVIN_JOIN]

查看特定表Marvin_Two 捕获日志
[yugong@rac2 MARVIN.MARVIN_TWO]$ pwd
/yugong/logs/MARVIN.MARVIN_TWO
[yugong@rac2 MARVIN.MARVIN_TWO]$  tail -200f extractor.log  
- Schema: MARVIN , Table: MARVIN_TWO , Type: I
-----------------
---Pks
        ColumnValue [column=ColumnMeta[name=ID,type=3], value=999]
---Columns
        ColumnValue [column=ColumnMeta[name=NAME,type=12], value=marvinn]
---END
-----------------
- Schema: MARVIN , Table: MARVIN_TWO , Type: I
-----------------
---Pks
        ColumnValue [column=ColumnMeta[name=ID,type=3], value=1000]
---Columns
        ColumnValue [column=ColumnMeta[name=NAME,type=12], value=marvinn]
---END
****************************************************
发现数据是已经被捕获,说明源端配置应该是正常...

查看特定表Marvin_Two 表日志
[yugong@rac2 MARVIN.MARVIN_TWO]$  tail -200f table.log  
Caused by: com.taobao.yugong.exception.YuGongException: table[MARVIN.marvin_two_1] is not found
        at com.taobao.yugong.common.db.meta.TableMetaGenerator$1.doInConnection(TableMetaGenerator.java:75)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:342)
        at com.taobao.yugong.common.db.meta.TableMetaGenerator.getTableMeta(TableMetaGenerator.java:51)
        at com.taobao.yugong.applier.FullRecordApplier.getSqlUnit(FullRecordApplier.java:197)
        at com.taobao.yugong.applier.FullRecordApplier.doApply(FullRecordApplier.java:87)
        at com.taobao.yugong.applier.MultiThreadFullRecordApplier$1.run(MultiThreadFullRecordApplier.java:93)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy.rejectedExecution(ThreadPoolExecutor.java:2022)
        at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823)
        at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369)
        at java.util.concurrent.ExecutorCompletionService.submit(ExecutorCompletionService.java:188)
        at com.taobao.yugong.common.utils.thread.ExecutorTemplate.submit(ExecutorTemplate.java:45)
        ... 5 more
 发现目标端,表[MARVIN.marvin_two_1] is not found,这是因为由于自定义数据转换配置没有设置表存放在哪个MYSQL数据库中,所以默认存放于当前的同名的SCHEMA中,当前环境为MARVIN,但是目标端没有在MARVIN数据库中创建表marvin_two_1,所以报错,再次修改自定义数据转换配置文件
  [yugong@rac2 translator]$vi MarvinTwoDataTranslator.java 
package com.taobao.yugong.translator;

import java.util.Arrays;
import java.util.List;

import com.google.common.collect.Lists;
import com.taobao.yugong.common.db.meta.ColumnValue;
import com.taobao.yugong.common.model.record.Record;

public class MarvinTwoDataTranslator extends AbstractDataTranslator implements DataTranslator {

    @Override
    public List<Record> translator(List<Record> records) {
        List<Record> result = Lists.newArrayListWithCapacity(records.size());
        for (Record record : records) {
            result.addAll(translatorOne(record));
        }

        return result;
    }

    public List<Record> translatorOne(Record record) {
        Record record1 = record;
        Record record2 = record.clone();
        Record record3 = record.clone();             // 需要给新增的同步映射字段,克隆一个记录Record模板,否则报错,无法链接

        record1.setSchemaName("test");             // 设置对应记录存放于目标端MYSQL中哪个数据库中(即存放SCHEMA 不同),默认值为存放跟源库同样的SCHEMA下,[该行配置文件,需要设置不同SCHEMA再配置,不需要可省略为默认]
        record1.setTableName("marvin_two_1");       // 目标端同步表名1
        // 1. 字段名字不同
        ColumnValue name1Column = record.getColumnByName("name");     // 源端单表映射字段
        if (name1Column != null) {
            name1Column.getColumn().setName("name_1");        //目标端同步表变更字段
        }

         // 未指定存放MYSQL哪个数据库下,目标端MYSQL拆分表记录存放于与源端默认SCHEMA下,即当前MARVIN下,若需指定,则只需要添加record2.setSchemaName("test"); 括号中填写指定的MYSQL数据库名,并创建对应的表名即可 ,以下以此类推
        record2.setTableName("marvin_two_2");
        // 1. 字段名字不同
        ColumnValue name2Column = record2.getColumnByName("name");
        if (name2Column != null) {
            name2Column.getColumn().setName("name_2");
        }

         // 未指定存放MYSQL哪个数据库下,目标端MYSQL拆分表记录存放于与源端默认SCHEMA下,即当前MARVIN下,若需指定,则只需要添加record3.setSchemaName("test"); 括号中填写指定的MYSQL数据库名,并创建对应的表名即可,以下以此类推
        record3.setTableName("marvin_two_3");
        // 1. 字段名字不同
        ColumnValue name3Column = record3.getColumnByName("name");
        if (name3Column != null) {
            name3Column.getColumn().setName("name_3");
        }
        return Arrays.asList(record1, record2, record3);        // 添加的表记录record,需要标明并返回到数组列表中
    }

}

重启yugong,并查看全局日志,显示正常:
2018-04-23 16:13:55.741 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.controller.YuGongInstance - table[MARVIN.MARVIN_TWO] is start
2018-04-23 16:13:58.100 [YuGongInstance-SCOTT.JOIN_NAME] INFO  com.taobao.yugong.controller.YuGongInstance - table[SCOTT.JOIN_NAME] is error , current status:NORMAL !
2018-04-23 16:14:55.381 [pool-2-thread-2] INFO  com.taobao.yugong.common.stats.ProgressTracer - {未启动:0,全量中:0,增量中:0,已追上:4,异常数:1}
2018-04-23 16:14:55.381 [pool-2-thread-2] INFO  com.taobao.yugong.common.stats.ProgressTracer - 异常数:[SCOTT.JOIN_NAME]
2018-04-23 16:14:55.381 [pool-2-thread-2] INFO  com.taobao.yugong.common.stats.ProgressTracer - 已完成:[MARVIN.ORACLE1, MARVIN.MARVIN_TWO, SCOTT.ORACLE2, MARVIN.MARVIN_JOIN]


查看特定表MARVIN_TWO表日志:
2018-04-23 16:13:56.961 [MultiThreadFullRecordApplier-MARVIN.MARVIN_TWO] ERROR com.taobao.yugong.applier.FullRecordApplier - skiped record data ,maybe transfer before,just continue:Record[schemaName=marvin,tableName=marvin_two_2,primaryKeys=[ColumnValue [column=ColumnMeta[name=ID,type=3], value=626]],columns=[ColumnValue [column=ColumnMeta[name=NAME_2,type=12], value=marvinn]]]
2018-04-23 16:13:56.961 [MultiThreadFullRecordApplier-MARVIN.MARVIN_TWO] ERROR com.taobao.yugong.applier.FullRecordApplier - skiped record data ,maybe transfer before,just continue:Record[schemaName=marvin,tableName=marvin_two_2,primaryKeys=[ColumnValue [column=ColumnMeta[name=ID,type=3], value=636]],columns=[ColumnValue [column=ColumnMeta[name=NAME_2,type=12], value=marvinn]]]
2018-04-23 16:13:56.962 [MultiThreadFullRecordApplier-MARVIN.MARVIN_TWO] ERROR com.taobao.yugong.applier.FullRecordApplier - skiped record data ,maybe transfer before,just continue:Record[schemaName=marvin,tableName=marvin_two_2,primaryKeys=[ColumnValue [column=ColumnMeta[name=ID,type=3], value=627]],columns=[ColumnValue [column=ColumnMeta[name=NAME_2,type=12], value=marvinn]]]
2018-04-23 16:13:56.962 [MultiThreadFullRecordApplier-MARVIN.MARVIN_TWO] ERROR com.taobao.yugong.applier.FullRecordApplier - skiped record data ,maybe transfer before,just continue:Record[schemaName=marvin,tableName=marvin_two_2,primaryKeys=[ColumnValue [column=ColumnMeta[name=ID,type=3], value=637]],columns=[ColumnValue [column=ColumnMeta[name=NAME_2,type=12], value=marvinn]]]
2018-04-23 16:13:56.962 [MultiThreadFullRecordApplier-MARVIN.MARVIN_TWO] ERROR com.taobao.yugong.applier.FullRecordApplier - skiped record data ,maybe transfer before,just continue:Record[schemaName=marvin,tableName=marvin_two_2,primaryKeys=[ColumnValue [column=ColumnMeta[name=ID,type=3], value=638]],columns=[ColumnValue [column=ColumnMeta[name=NAME_2,type=12], value=marvinn]]]
2018-04-23 16:13:58.283 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:5000,采样记录数:5000,同步TPS:1967,最长时间:1386,最小时间:151,平均时间:508}
2018-04-23 16:13:58.901 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:10000,采样记录数:5000,同步TPS:8090,最长时间:155,最小时间:105,平均时间:123}
2018-04-23 16:13:59.441 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:15000,采样记录数:5000,同步TPS:9259,最长时间:125,最小时间:96,平均时间:108}
2018-04-23 16:13:59.961 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:20000,采样记录数:5000,同步TPS:9615,最长时间:118,最小时间:83,平均时间:104}
2018-04-23 16:14:00.455 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:25000,采样记录数:5000,同步TPS:10121,最长时间:125,最小时间:85,平均时间:98}
2018-04-23 16:14:00.945 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:30000,采样记录数:5000,同步TPS:10224,最长时间:119,最小时间:87,平均时间:97}
2018-04-23 16:14:01.433 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:35000,采样记录数:5000,同步TPS:10266,最长时间:137,最小时间:76,平均时间:97}
2018-04-23 16:14:01.928 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:40000,采样记录数:5000,同步TPS:10101,最长时间:155,最小时间:84,平均时间:99}
                ............................................................
2018-04-23 16:14:07.868 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:100000,采样记录数:5000,同步TPS:11467,最长时间:100,最小时间:78,平均时间:87}
2018-04-23 16:14:07.868 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  c.t.yugong.extractor.oracle.OracleAllRecordExtractor - table [MARVIN.MARVIN_TWO] full extractor is end , next auto start inc extracto

发现报错,ERROR报错,但是其实数据仍然是已经同步到了目标三张表中.....其中一张在TEST数据库,两张在MARVIN数据库.....

注意:刚开始接触单表同步多表,按某个字段做映射,以为是做数据分片分割,原来实际是相当于,再目标库中复制了三张同数据内容,单不同表明以及单个表字段不同的数据表….

为此,我将配置改成原始配置文件,发现也是源端与目标端同步表数据量都对等的.....

注意:重新做全量,需要删除MARVIN_MARVIN_TWO.dat 以及日志文件,重启yugong才可以...
[yugong@rac2 positioner]$ rm -rf MARVIN_MARVIN_TWO.dat 
[yugong@rac2 positioner]$ 

[yugong@rac2 logs]$ rm -rf MARVIN.MARVIN_TWO/
[yugong@rac2 logs]$ 

发现特定表日志如下:
2018-04-23 15:28:50.278 [main] WARN  c.t.yugong.extractor.oracle.OracleRecRecordExtractor - mlog[MLOG$_MARVIN_TWO] is exist, just have fun.
2018-04-23 15:28:50.432 [main] INFO  c.t.y.e.o.OracleFullRecordExtractor$ContinueExtractor - MARVIN.MARVIN_TWO start postion:0
2018-04-23 15:28:50.465 [main] INFO  com.taobao.yugong.controller.YuGongInstance - table[MARVIN.MARVIN_TWO] start successful. extractor:com.taobao.yugong.extractor.oracle.OracleAllRecordExtractor , applier:com.taobao.yugong.applier.AllRecordApplier, translator:com.taobao.yugong.translator.MarvinTwoDataTranslator

其实,从applier:com.taobao.yugong.applier.AllRecordApplier 这里就可以看出是表是全记录应用,唯一不同的是多个表同时同步数据.....

2018-04-23 15:28:52.371 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:5000,采样记录数:5000,同步TPS:2656,最长时间:926,最小时间:159,平均时间:376}
2018-04-23 15:28:52.976 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:10000,采样记录数:5000,同步TPS:8264,最长时间:137,最小时间:111,平均时间:121}
2018-04-23 15:28:53.503 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:15000,采样记录数:5000,同步TPS:9505,最长时间:139,最小时间:84,平均时间:105}
2018-04-23 15:28:53.980 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:20000,采样记录数:5000,同步TPS:10482,最长时间:118,最小时间:87,平均时间:95}
2018-04-23 15:28:54.473 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:25000,采样记录数:5000,同步TPS:10141,最长时间:112,最小时间:88,平均时间:98}
2018-04-23 15:28:54.904 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:30000,采样记录数:5000,同步TPS:11600,最长时间:97,最小时间:78,平均时间:86}
2018-04-23 15:28:55.485 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:35000,采样记录数:5000,同步TPS:8605,最长时间:213,最小时间:77,平均时间:116}
2018-04-23 15:28:55.950 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:40000,采样记录数:5000,同步TPS:10775,最长时间:123,最小时间:78,平均时间:92}
2018-04-23 15:28:56.464 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:45000,采样记录数:5000,同步TPS:9727,最长时间:151,最小时间:81,平均时间:102}
2018-04-23 15:28:56.891 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:50000,采样记录数:5000,同步TPS:11709,最长时间:107,最小时间:79,平均时间:85}
2018-04-23 15:28:57.324 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:55000,采样记录数:5000,同步TPS:11547,最长时间:96,最小时间:79,平均时间:86}
2018-04-23 15:28:57.817 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  com.taobao.yugong.common.stats.StatAggregation - {总记录数:60000,采样记录数:5000,同步TPS:10141,最长时间:124,最小时间:78,平均时间:98}
@
2018-04-23 15:52:36.530 [YuGongInstance-MARVIN.MARVIN_TWO] INFO  c.t.y.e.oracle.OracleMaterializedIncRecordExtractor - table[MARVIN.MARVIN_TWO] now is NO_UPDATE ...

并无上面存放不同SCHEMA的报错,但是源端与目标端同步表数据量都对等的....所以,该模版就是做单表同步多表,而不是拆分....真是尴尬....

验证数据:http://www.cndba.cn/Marvinn/article/2747

源端:

SQL> select count(*) from marvin.marvin_two;

  COUNT(*)
----------
    100000

目标端MYSQL:
mysql> use test;
Database changed
mysql> select count(*) from marvin_two_1;
+----------+
| count(*) |
+----------+
|   100000 |
+----------+
1 row in set (0.02 sec)

mysql> use marvin;
Database changed
mysql> select count(*) from marvin_two_2;
+----------+
| count(*) |
+----------+
|   100000 |
+----------+
1 row in set (0.01 sec)

mysql> select count(*) from marvin_two_3;
+----------+
| count(*) |
+----------+
|   100000 |
+----------+
1 row in set (0.01 sec)

至此…. YuGong ORACLE 迁移 MYSQL (单表同步多表)成功….http://www.cndba.cn/Marvinn/article/2747

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
Marvinn

Marvinn

关注

路漫漫其修远兮、吾将上下而求索

  • 99
    原创
  • 0
    翻译
  • 2
    转载
  • 36
    评论
  • 访问:458484次
  • 积分:449
  • 等级:中级会员
  • 排名:第12名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ