DATAX之MysqlReader和MysqlWriter

核心
1、MysqlReader介绍
2、MysqlWriter介绍
3、案例测试

Mysql Reader
1 、快速介绍
        MysqlReader插件实现了从Mysql读取数据。在底层实现上,MysqlReader通过JDBC连接远程Mysql数据库,并执行相应的sql语句将数据从mysql库中SELECT出来。不同于其他关系型数据库,MysqlReader不支持FetchSize.

2、实现原理
        简而言之,MysqlReader通过JDBC连接器连接到远程的Mysql数据库,并根据用户配置的信息生成查询SELECT SQL语句,然后发送到远程Mysql数据库,并将该SQL执行返回结果使用DataX自定义的数据类型拼装为抽象的数据集,并传递给下游Writer处理。对于用户配置Table、Column、Where的信息,MysqlReader将其拼接为SQL语句发送到Mysql数据库;对于用户配置querySql信息,MysqlReader直接将其发送到Mysql数据库。

3、参数说明
    ● jdbcUrl
        ○ 描述:描述的是到对端数据库的JDBC连接信息,使用JSON的数组描述,并支持一个库填写多个连接地址。之所以使用JSON数组描述连接信息,
        ○ 必选:是
        ○ 默认值:无
    ● username
        ○ 描述:数据源的用户名
        ○ 必选:是
        ○ 默认值:无
    ● password
        ○ 描述:数据源指定用户名的密码
        ○ 必选:是
        ○ 默认值:无
    ● table
        ○ 描述:所选取的需要同步的表。使用JSON的数组描述,因此支持多张表同时抽取。当配置为多张表时,用户自己需保证多张表是同一schema结构,MysqlReader不予检查表是否同一逻辑表。注意,table必须包含在connection配置单元中。
        ○ 必选:是
        ○ 默认值:无
    ● column
        ○ 描述:所配置的表中需要同步的列名集合,使用JSON的数组描述字段信息。用户使用*代表默认使用所有列配置,例如[‘*’]。
支持列裁剪,即列可以挑选部分列进行导出。
支持列换序,即列可以不按照表schema信息进行导出。
支持常量配置,用户需要按照Mysql SQL语法格式: [“id”, “table“, “1”, “‘bazhen.csy’”, “null”, “to_char(a + 1)”, “2.3” , “true”] id为普通列名,table为包含保留在的列名,1为整形数字常量,’bazhen.csy’为字符串常量,null为空指针,to_char(a + 1)为表达式,2.3为浮点数,true为布尔值。
        ○ 必选:是
        ○ 默认值:无
    ● splitPk
        ○ 描述:MysqlReader进行数据抽取时,如果指定splitPk,表示用户希望使用splitPk代表的字段进行数据分片,DataX因此会启动并发任务进行数据同步,这样可以大大提供数据同步的效能。
推荐splitPk用户使用表主键,因为表主键通常情况下比较均匀,因此切分出来的分片也不容易出现数据热点。
目前splitPk仅支持整形数据切分,不支持浮点、字符串、日期等其他类型。如果用户指定其他非支持类型,MysqlReader将报错!如果splitPk不填写,包括不提供splitPk或者splitPk值为空,DataX视作使用单通道同步该表数据。
        ○ 必选:否
        ○ 默认值:空
    ● where
        ○ 描述:筛选条件,MysqlReader根据指定的column、table、where条件拼接SQL,并根据这个SQL进行数据抽取。在实际业务场景中,往往会选择当天的数据进行同步,可以将where条件指定为gmt_create > $bizdate 。注意:不可以将where条件指定为limit 10,limit不是SQL的合法where子句。
where条件可以有效地进行业务增量同步。如果不填写where语句,包括不提供where的key或者value,DataX均视作同步全量数据。
        ○ 必选:否
        ○ 默认值:无
    ● querySql
        ○ 描述:在有些业务场景下,where这一配置项不足以描述所筛选的条件,用户可以通过该配置型来自定义筛选SQL。当用户配置了这一项之后,DataX系统就会忽略table,column这些配置型,直接使用这个配置项的内容对数据进行筛选,例如需要进行多表join后同步数据,使用select a,b from table_a join table_b on table_a.id = table_b.id
当用户配置querySql时,MysqlReader直接忽略table、column、where条件的配置,querySql优先级大于table、column、where选项。
        ○ 必选:否
        ○ 默认值:无

MysqlWriter
1、快速介绍
        MysqlWriter 插件实现了写入数据到 Mysql 主库的目的表的功能。在底层实现上, MysqlWriter 通过 JDBC 连接远程 Mysql 数据库,并执行相应的 insert into … 或者 ( replace into …) 的 sql 语句将数据写入 Mysql,内部会分批次提交入库,需要数据库本身采用 innodb 引擎。MysqlWriter 面向ETL开发工程师,他们使用 MysqlWriter 从数仓导入数据到 Mysql。同时 MysqlWriter 亦可以作为数据迁移工具为DBA等用户提供服务

2、实现原理
MysqlWriter 通过 DataX 框架获取 Reader 生成的协议数据,根据你配置的 writeMode 生成
● insert into…(当主键/唯一性索引冲突时会写不进去冲突的行)
或者
● replace into…(没有遇到主键/唯一性索引冲突时,与 insert into 行为一致,冲突时会用新行替换原有行所有字段) 的语句写入数据到 Mysql。出于性能考虑,采用了 PreparedStatement + Batch,并且设置了:rewriteBatchedStatements=true,将数据缓冲到线程上下文 Buffer 中,当 Buffer 累计到预定阈值时,才发起写入请求。

注意:目的表所在数据库必须是主库才能写入数据;整个任务至少需要具备 insert/replace
into…的权限,是否需要其他权限,取决于你任务配置中在 preSql 和 postSql 中指定的语句。

3、参数说明
    ● jdbcUrl
        ○ 描述:目的数据库的 JDBC 连接信息。作业运行时,DataX 会在你提供的 jdbcUrl 后面追加如下属性:yearIsDateType=false&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true

1、在一个数据库上只能配置一个 jdbcUrl 值。这与 MysqlReader支持多个备库探测不同,因为此处不支持同一个数据库存在多个主库的情况(双主导入数据情况)
2、jdbcUrl按照Mysql官方规范,并可以填写连接附加控制信息,比如想指定连接编码为 gbk ,则在 jdbcUrl 后面追加属性 useUnicode=true&characterEncoding=gbk。

        ○ 必选:是
        ○ 默认值:无
    ● username
        ○ 描述:目的数据库的用户名
        ○ 必选:是
        ○ 默认值:无
    ● password
        ○ 描述:目的数据库的密码
        ○ 必选:是
        ○ 默认值:无
    ● table
        ○ 描述:目的表的表名称。支持写入一个或者多个表。当配置为多张表时,必须确保所有表结构保持一致。

table 和 jdbcUrl 必须包含在 connection 配置单元中

        ○ 必选:是
        ○ 默认值:无
    ● column
        ○ 描述:目的表需要写入数据的字段,字段之间用英文逗号分隔。例如: “column”: [“id”,”name”,”age”]。如果要依次写入全部列,使用表示, 例如: “column”: [“”]。 **column配置项必须指定,不能留空!**

1、我们强烈不推荐你这样配置,因为当你目的表字段个数、类型等有改动时,你的任务可能运行不正确或者失败
2、 column 不能配置任何常量值

        ○ 必选:是
        ○ 默认值:否
    ● session
        ○ 描述: DataX在获取Mysql连接时,执行session指定的SQL语句,修改当前connection session属性
        ○ 必须: 否
        ○ 默认值: 空
    ● preSql
        ○ 描述:写入数据到目的表前,会先执行这里的标准语句。如果 Sql 中有你需要操作到的表名称,这样在实际执行 Sql 语句时,会对变量按照实际表名称进行替换。比如你的任务是要写入到目的端的100个同构分表(表名称为:datax_00,datax01, … datax_98,datax_99),并且你希望导入数据前,先对表中数据进行删除操作,那么你可以这样配置:”preSql”:[“delete from 表名”],效果是:在执行到每个表写入数据前,会先执行对应的 delete from 对应表名称
        ○ 必选:否
        ○ 默认值:无
    ● postSql
        ○ 描述:写入数据到目的表后,会执行这里的标准语句。(原理同 preSql )
        ○ 必选:否
        ○ 默认值:无
    ● writeMode
        ○ 描述:控制写入数据到目标表采用 insert into 或者 replace into 或者 ON DUPLICATE KEY UPDATE 语句
        ○ 必选:是
        ○ 所有选项:insert/replace/update
        ○ 默认值:insert
    ● batchSize
        ○ 描述:一次性批量提交的记录数大小,该值可以极大减少DataX与Mysql的网络交互次数,并提升整体吞吐量。但是该值设置过大可能会造成DataX运行进程OOM情况。
        ○ 必选:否
        ○ 默认值:1024

案例测试

数据准备

create table datax(
id bigint(20) not null,
name varchar(4000),
bir_date datetime
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

insert into datax(id,name,bir_date) values(1,"xlucas","2011-10-24 17:56:34");
insert into datax(id,name,bir_date) values(2,"xlucas1","2012-10-24 17:56:34");
insert into datax(id,name,bir_date) values(3,"xlucas2","2013-10-24 17:56:34");
insert into datax(id,name,bir_date) values(4,"xlucas3","2014-10-24 17:56:34");

datax job准备

{
    "job": {
        "setting": {
            "speed": {
                 "channel": 3
            },
            "errorLimit": {
                "record": 0,
                "percentage": 0.02
            }
        },
        "content": [
            {
                "reader": {
                    "name": "mysqlreader",
                    "parameter": {
                        "username": "root",
                        "password": "123456",
                        "column": [ "id", "name", "bir_date" ],
                        "splitPk": "id",
                        "connection": [ { "table": [ "datax" ], "jdbcUrl": [ "jdbc:mysql://192.168.18.160/datax" ] } ] }
                },
               "writer": {
                    "name": "streamwriter",
                    "parameter": {
                        "print":true }
                }
            }
        ]
    }
}

这个是直接打印在终端上面

[hadoop@cdh2 bin]$ python datax.py ../job/mysql1.json 

DataX (DATAX-OPENSOURCE-3.0), From Alibaba !
Copyright (C) 2010-2017, Alibaba Group. All Rights Reserved.


2018-03-18 23:16:14.084 [main] INFO  VMInfo - VMInfo# operatingSystem class => sun.management.OperatingSystemImpl
2018-03-18 23:16:14.134 [main] INFO  Engine - the machine info  => 

        osInfo: Oracle Corporation 1.8 25.111-b14
        jvmInfo:        Linux amd64 2.6.32-431.el6.x86_64
        cpu num:        6

        totalPhysicalMemory:    -0.00G
        freePhysicalMemory:     -0.00G
        maxFileDescriptorCount: -1
        currentOpenFileDescriptorCount: -1

        GC Names        [PS MarkSweep, PS Scavenge]

        MEMORY_NAME                    | allocation_size                | init_size                      
        PS Eden Space                  | 256.00MB                       | 256.00MB                       
        Code Cache                     | 240.00MB                       | 2.44MB                         
        Compressed Class Space         | 1,024.00MB                     | 0.00MB                         
        PS Survivor Space              | 42.50MB                        | 42.50MB                        
        PS Old Gen                     | 683.00MB                       | 683.00MB                       
        Metaspace                      | -0.00MB                        | 0.00MB                         


2018-03-18 23:16:14.239 [main] INFO  Engine - 
{
        "content":[
                {
                        "reader":{
                                "name":"mysqlreader",
                                "parameter":{
                                        "column":[
                                                "id",
                                                "name",
                                                "bir_date"
                                        ],
                                        "connection":[
                                                {
                                                        "jdbcUrl":[
                                                                "jdbc:mysql://192.168.18.160/datax"
                                                        ],
                                                        "table":[
                                                                "datax"
                                                        ]
                                                }
                                        ],
                                        "password":"******",
                                        "splitPk":"id",
                                        "username":"root"
                                }
                        },
                        "writer":{
                                "name":"streamwriter",
                                "parameter":{
                                        "print":true
                                }
                        }
                }
        ],
        "setting":{
                "errorLimit":{
                        "percentage":0.02,
                        "record":0
                },
                "speed":{
                        "channel":3
                }
        }
}



2018-03-18 23:16:14.315 [main] WARN  Engine - prioriy set to 0, because NumberFormatException, the value is: null
2018-03-18 23:16:14.320 [main] INFO  PerfTrace - PerfTrace traceId=job_-1, isEnable=false, priority=0
2018-03-18 23:16:14.320 [main] INFO  JobContainer - DataX jobContainer starts job.
2018-03-18 23:16:14.326 [main] INFO  JobContainer - Set jobId = 0
2018-03-18 23:16:15.682 [job-0] INFO  OriginalConfPretreatmentUtil - Available jdbcUrl:jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true.
2018-03-18 23:16:15.719 [job-0] INFO  OriginalConfPretreatmentUtil - table:[datax] has columns:[id,name,bir_date].
2018-03-18 23:16:15.757 [job-0] INFO  JobContainer - jobContainer starts to do prepare ...
2018-03-18 23:16:15.758 [job-0] INFO  JobContainer - DataX Reader.Job [mysqlreader] do prepare work .
2018-03-18 23:16:15.759 [job-0] INFO  JobContainer - DataX Writer.Job [streamwriter] do prepare work .
2018-03-18 23:16:15.759 [job-0] INFO  JobContainer - jobContainer starts to do split ...
2018-03-18 23:16:15.759 [job-0] INFO  JobContainer - Job set Channel-Number to 3 channels.
2018-03-18 23:16:15.773 [job-0] INFO  SingleTableSplitUtil - split pk [sql=SELECT MIN(id),MAX(id) FROM datax] is running... 
2018-03-18 23:16:15.843 [job-0] INFO  SingleTableSplitUtil - After split(), allQuerySql=[
select id,name,bir_date from datax  where  (1 <= id AND id < 2) 
select id,name,bir_date from datax  where  (2 <= id AND id < 3) 
select id,name,bir_date from datax  where  (3 <= id AND id <= 4) 
select id,name,bir_date from datax  where  id IS NULL
].
2018-03-18 23:16:15.843 [job-0] INFO  JobContainer - DataX Reader.Job [mysqlreader] splits to [4] tasks.
2018-03-18 23:16:15.844 [job-0] INFO  JobContainer - DataX Writer.Job [streamwriter] splits to [4] tasks.
2018-03-18 23:16:15.874 [job-0] INFO  JobContainer - jobContainer starts to do schedule ...
2018-03-18 23:16:15.892 [job-0] INFO  JobContainer - Scheduler starts [1] taskGroups.
2018-03-18 23:16:15.895 [job-0] INFO  JobContainer - Running by standalone Mode.
2018-03-18 23:16:15.912 [taskGroup-0] INFO  TaskGroupContainer - taskGroupId=[0] start [3] channels for [4] tasks.
2018-03-18 23:16:15.925 [taskGroup-0] INFO  Channel - Channel set byte_speed_limit to -1, No bps activated.
2018-03-18 23:16:15.925 [taskGroup-0] INFO  Channel - Channel set record_speed_limit to -1, No tps activated.
2018-03-18 23:16:15.950 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[3] attemptCount[1] is started
2018-03-18 23:16:15.961 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[0] attemptCount[1] is started
2018-03-18 23:16:15.973 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[2] attemptCount[1] is started
2018-03-18 23:16:15.974 [0-0-3-reader] INFO  CommonRdbmsReader$Task - Begin to read record by Sql: [select id,name,bir_date from datax  where  id IS NULL
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:16:15.991 [0-0-2-reader] INFO  CommonRdbmsReader$Task - Begin to read record by Sql: [select id,name,bir_date from datax  where  (3 <= id AND id <= 4) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:16:15.991 [0-0-0-reader] INFO  CommonRdbmsReader$Task - Begin to read record by Sql: [select id,name,bir_date from datax  where  (1 <= id AND id < 2) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:16:16.005 [0-0-3-reader] INFO  CommonRdbmsReader$Task - Finished read record by Sql: [select id,name,bir_date from datax  where  id IS NULL
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:16:16.023 [0-0-0-reader] INFO  CommonRdbmsReader$Task - Finished read record by Sql: [select id,name,bir_date from datax  where  (1 <= id AND id < 2) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:16:16.027 [0-0-2-reader] INFO  CommonRdbmsReader$Task - Finished read record by Sql: [select id,name,bir_date from datax  where  (3 <= id AND id <= 4) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
1       xlucas  2011-10-24 17:56:34
3       xlucas2 2013-10-24 17:56:34
4       xlucas3 2014-10-24 17:56:34
2018-03-18 23:16:16.175 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[0] is successed, used[222]ms
2018-03-18 23:16:16.175 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[2] is successed, used[202]ms
2018-03-18 23:16:16.178 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[1] attemptCount[1] is started
2018-03-18 23:16:16.190 [0-0-1-reader] INFO  CommonRdbmsReader$Task - Begin to read record by Sql: [select id,name,bir_date from datax  where  (2 <= id AND id < 3) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:16:16.203 [0-0-1-reader] INFO  CommonRdbmsReader$Task - Finished read record by Sql: [select id,name,bir_date from datax  where  (2 <= id AND id < 3) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2       xlucas1 2012-10-24 17:56:34
2018-03-18 23:16:16.279 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[1] is successed, used[101]ms
2018-03-18 23:16:16.280 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[3] is successed, used[340]ms
2018-03-18 23:16:16.281 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] completed it's tasks.
2018-03-18 23:16:25.917 [job-0] INFO  StandAloneJobContainerCommunicator - Total 4 records, 63 bytes | Speed 6B/s, 0 records/s | Error 0 records, 0 bytes |  All Task WaitWriterTime 0.000s |  All Task WaitReaderTime 0.054s | Percentage 100.00%
2018-03-18 23:16:25.918 [job-0] INFO  AbstractScheduler - Scheduler accomplished all tasks.
2018-03-18 23:16:25.920 [job-0] INFO  JobContainer - DataX Writer.Job [streamwriter] do post work.
2018-03-18 23:16:25.921 [job-0] INFO  JobContainer - DataX Reader.Job [mysqlreader] do post work.
2018-03-18 23:16:25.922 [job-0] INFO  JobContainer - DataX jobId [0] completed successfully.
2018-03-18 23:16:25.925 [job-0] INFO  HookInvoker - No hook invoked, because base dir not exists or is a file: /opt/datax/hook
2018-03-18 23:16:25.928 [job-0] INFO  JobContainer - 
         [total cpu info] => 
                averageCpu                     | maxDeltaCpu                    | minDeltaCpu                    
                -1.00%                         | -1.00%                         | -1.00%


         [total gc info] => 
                 NAME                 | totalGCCount       | maxDeltaGCCount    | minDeltaGCCount    | totalGCTime        | maxDeltaGCTime     | minDeltaGCTime     
                 PS MarkSweep         | 0                  | 0                  | 0                  | 0.000s             | 0.000s             | 0.000s             
                 PS Scavenge          | 0                  | 0                  | 0                  | 0.000s             | 0.000s             | 0.000s             

2018-03-18 23:16:25.928 [job-0] INFO  JobContainer - PerfTrace not enable!
2018-03-18 23:16:25.930 [job-0] INFO  StandAloneJobContainerCommunicator - Total 4 records, 63 bytes | Speed 6B/s, 0 records/s | Error 0 records, 0 bytes |  All Task WaitWriterTime 0.000s |  All Task WaitReaderTime 0.054s | Percentage 100.00%
2018-03-18 23:16:25.933 [job-0] INFO  JobContainer - 
任务启动时刻                    : 2018-03-18 23:16:14
任务结束时刻                    : 2018-03-18 23:16:25
任务总计耗时                    :                 11s
任务平均流量                    :                6B/s
记录写入速度                    :              0rec/s
读出记录总数                    :                   4
读写失败总数                    :                   0

datax job准备

{
    "job": {
        "setting": {
            "speed": {
                 "channel": 3
            },
            "errorLimit": {
                "record": 0,
                "percentage": 0.02
            }
        },
        "content": [
            {
                "reader": {
                    "name": "mysqlreader",
                    "parameter": {
                        "username": "root",
                        "password": "123456",
                        "column": [ "id", "name", "bir_date" ],
                        "splitPk": "id",
                        "connection": [ { "table": [ "datax" ], "jdbcUrl": [ "jdbc:mysql://192.168.18.160/datax" ] } ] }
                },
              "writer": {
                    "name": "mysqlwriter",
                    "parameter": {
                        "writeMode": "insert",
                        "username": "root",
                        "password": "123456",
                        "column": [ "id", "name", "bir_date" ],
                        "session": [ "set session sql_mode='ANSI'" ],
                        "preSql": [ "delete from datax1" ],
                        "connection": [ { "jdbcUrl": "jdbc:mysql://192.168.18.160/datax?useUnicode=true&characterEncoding=gbk", "table": [ "datax1" ] } ] }
                }
            }
        ]
    }
}

从mysql中读取出来,写入到另外一个表里面

[hadoop@cdh2 bin]$ python datax.py ../job/mysql.json 

DataX (DATAX-OPENSOURCE-3.0), From Alibaba !
Copyright (C) 2010-2017, Alibaba Group. All Rights Reserved.


2018-03-18 23:22:33.014 [main] INFO  VMInfo - VMInfo# operatingSystem class => sun.management.OperatingSystemImpl
2018-03-18 23:22:33.023 [main] INFO  Engine - the machine info  => 

        osInfo: Oracle Corporation 1.8 25.111-b14
        jvmInfo:        Linux amd64 2.6.32-431.el6.x86_64
        cpu num:        6

        totalPhysicalMemory:    -0.00G
        freePhysicalMemory:     -0.00G
        maxFileDescriptorCount: -1
        currentOpenFileDescriptorCount: -1

        GC Names        [PS MarkSweep, PS Scavenge]

        MEMORY_NAME                    | allocation_size                | init_size                      
        PS Eden Space                  | 256.00MB                       | 256.00MB                       
        Code Cache                     | 240.00MB                       | 2.44MB                         
        Compressed Class Space         | 1,024.00MB                     | 0.00MB                         
        PS Survivor Space              | 42.50MB                        | 42.50MB                        
        PS Old Gen                     | 683.00MB                       | 683.00MB                       
        Metaspace                      | -0.00MB                        | 0.00MB                         


2018-03-18 23:22:33.049 [main] INFO  Engine - 
{
        "content":[
                {
                        "reader":{
                                "name":"mysqlreader",
                                "parameter":{
                                        "column":[
                                                "id",
                                                "name",
                                                "bir_date"
                                        ],
                                        "connection":[
                                                {
                                                        "jdbcUrl":[
                                                                "jdbc:mysql://192.168.18.160/datax"
                                                        ],
                                                        "table":[
                                                                "datax"
                                                        ]
                                                }
                                        ],
                                        "password":"******",
                                        "splitPk":"id",
                                        "username":"root"
                                }
                        },
                        "writer":{
                                "name":"mysqlwriter",
                                "parameter":{
                                        "column":[
                                                "id",
                                                "name",
                                                "bir_date"
                                        ],
                                        "connection":[
                                                {
                                                        "jdbcUrl":"jdbc:mysql://192.168.18.160/datax?useUnicode=true&characterEncoding=gbk",
                                                        "table":[
                                                                "datax1"
                                                        ]
                                                }
                                        ],
                                        "password":"******",
                                        "preSql":[
                                                "delete from datax1"
                                        ],
                                        "session":[
                                                "set session sql_mode='ANSI'"
                                        ],
                                        "username":"root",
                                        "writeMode":"insert"
                                }
                        }
                }
        ],
        "setting":{
                "errorLimit":{
                        "percentage":0.02,
                        "record":0
                },
                "speed":{
                        "channel":3
                }
        }
}

2018-03-18 23:22:33.073 [main] WARN  Engine - prioriy set to 0, because NumberFormatException, the value is: null
2018-03-18 23:22:33.075 [main] INFO  PerfTrace - PerfTrace traceId=job_-1, isEnable=false, priority=0
2018-03-18 23:22:33.075 [main] INFO  JobContainer - DataX jobContainer starts job.
2018-03-18 23:22:33.078 [main] INFO  JobContainer - Set jobId = 0
2018-03-18 23:22:33.518 [job-0] INFO  OriginalConfPretreatmentUtil - Available jdbcUrl:jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true.
2018-03-18 23:22:33.541 [job-0] INFO  OriginalConfPretreatmentUtil - table:[datax] has columns:[id,name,bir_date].
2018-03-18 23:22:34.197 [job-0] INFO  OriginalConfPretreatmentUtil - table:[datax1] all columns:[
id,name,bir_date
].
2018-03-18 23:22:34.210 [job-0] INFO  OriginalConfPretreatmentUtil - Write data [
insert INTO %s (id,name,bir_date) VALUES(?,?,?)
], which jdbcUrl like:[jdbc:mysql://192.168.18.160/datax?useUnicode=true&characterEncoding=gbk&yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true]
2018-03-18 23:22:34.210 [job-0] INFO  JobContainer - jobContainer starts to do prepare ...
2018-03-18 23:22:34.211 [job-0] INFO  JobContainer - DataX Reader.Job [mysqlreader] do prepare work .
2018-03-18 23:22:34.211 [job-0] INFO  JobContainer - DataX Writer.Job [mysqlwriter] do prepare work .
2018-03-18 23:22:34.222 [job-0] INFO  CommonRdbmsWriter$Job - Begin to execute preSqls:[delete from datax1]. context info:jdbc:mysql://192.168.18.160/datax?useUnicode=true&characterEncoding=gbk&yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true.
2018-03-18 23:22:34.223 [job-0] INFO  JobContainer - jobContainer starts to do split ...
2018-03-18 23:22:34.224 [job-0] INFO  JobContainer - Job set Channel-Number to 3 channels.
2018-03-18 23:22:34.236 [job-0] INFO  SingleTableSplitUtil - split pk [sql=SELECT MIN(id),MAX(id) FROM datax] is running... 
2018-03-18 23:22:34.259 [job-0] INFO  SingleTableSplitUtil - After split(), allQuerySql=[
select id,name,bir_date from datax  where  (1 <= id AND id < 2) 
select id,name,bir_date from datax  where  (2 <= id AND id < 3) 
select id,name,bir_date from datax  where  (3 <= id AND id <= 4) 
select id,name,bir_date from datax  where  id IS NULL
].
2018-03-18 23:22:34.260 [job-0] INFO  JobContainer - DataX Reader.Job [mysqlreader] splits to [4] tasks.
2018-03-18 23:22:34.261 [job-0] INFO  JobContainer - DataX Writer.Job [mysqlwriter] splits to [4] tasks.
2018-03-18 23:22:34.285 [job-0] INFO  JobContainer - jobContainer starts to do schedule ...
2018-03-18 23:22:34.293 [job-0] INFO  JobContainer - Scheduler starts [1] taskGroups.
2018-03-18 23:22:34.296 [job-0] INFO  JobContainer - Running by standalone Mode.
2018-03-18 23:22:34.306 [taskGroup-0] INFO  TaskGroupContainer - taskGroupId=[0] start [3] channels for [4] tasks.
2018-03-18 23:22:34.310 [taskGroup-0] INFO  Channel - Channel set byte_speed_limit to -1, No bps activated.
2018-03-18 23:22:34.310 [taskGroup-0] INFO  Channel - Channel set record_speed_limit to -1, No tps activated.
2018-03-18 23:22:34.320 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[1] attemptCount[1] is started
2018-03-18 23:22:34.324 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[0] attemptCount[1] is started
2018-03-18 23:22:34.327 [0-0-0-reader] INFO  CommonRdbmsReader$Task - Begin to read record by Sql: [select id,name,bir_date from datax  where  (1 <= id AND id < 2) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:22:34.327 [0-0-1-reader] INFO  CommonRdbmsReader$Task - Begin to read record by Sql: [select id,name,bir_date from datax  where  (2 <= id AND id < 3) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:22:34.328 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[2] attemptCount[1] is started
2018-03-18 23:22:34.335 [0-0-2-reader] INFO  CommonRdbmsReader$Task - Begin to read record by Sql: [select id,name,bir_date from datax  where  (3 <= id AND id <= 4) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:22:34.335 [0-0-1-writer] INFO  DBUtil - execute sql:[set session sql_mode='ANSI']
2018-03-18 23:22:34.347 [0-0-0-writer] INFO  DBUtil - execute sql:[set session sql_mode='ANSI']
2018-03-18 23:22:34.356 [0-0-1-writer] INFO  DBUtil - execute sql:[set session sql_mode='ANSI']
2018-03-18 23:22:34.356 [0-0-1-reader] INFO  CommonRdbmsReader$Task - Finished read record by Sql: [select id,name,bir_date from datax  where  (2 <= id AND id < 3) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:22:34.356 [0-0-2-reader] INFO  CommonRdbmsReader$Task - Finished read record by Sql: [select id,name,bir_date from datax  where  (3 <= id AND id <= 4) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:22:34.367 [0-0-2-writer] INFO  DBUtil - execute sql:[set session sql_mode='ANSI']
2018-03-18 23:22:34.379 [0-0-0-reader] INFO  CommonRdbmsReader$Task - Finished read record by Sql: [select id,name,bir_date from datax  where  (1 <= id AND id < 2) 
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:22:34.384 [0-0-0-writer] INFO  DBUtil - execute sql:[set session sql_mode='ANSI']
2018-03-18 23:22:34.391 [0-0-2-writer] INFO  DBUtil - execute sql:[set session sql_mode='ANSI']
2018-03-18 23:22:34.430 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[0] is successed, used[107]ms
2018-03-18 23:22:34.431 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[1] is successed, used[113]ms
2018-03-18 23:22:34.431 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[2] is successed, used[104]ms
2018-03-18 23:22:34.434 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[3] attemptCount[1] is started
2018-03-18 23:22:34.455 [0-0-3-reader] INFO  CommonRdbmsReader$Task - Begin to read record by Sql: [select id,name,bir_date from datax  where  id IS NULL
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:22:34.465 [0-0-3-writer] INFO  DBUtil - execute sql:[set session sql_mode='ANSI']
2018-03-18 23:22:34.467 [0-0-3-reader] INFO  CommonRdbmsReader$Task - Finished read record by Sql: [select id,name,bir_date from datax  where  id IS NULL
] jdbcUrl:[jdbc:mysql://192.168.18.160/datax?yearIsDateType=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&rewriteBatchedStatements=true].
2018-03-18 23:22:34.475 [0-0-3-writer] INFO  DBUtil - execute sql:[set session sql_mode='ANSI']
2018-03-18 23:22:34.535 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] taskId[3] is successed, used[101]ms
2018-03-18 23:22:34.536 [taskGroup-0] INFO  TaskGroupContainer - taskGroup[0] completed it's tasks.
2018-03-18 23:22:44.320 [job-0] INFO  StandAloneJobContainerCommunicator - Total 4 records, 63 bytes | Speed 6B/s, 0 records/s | Error 0 records, 0 bytes |  All Task WaitWriterTime 0.000s |  All Task WaitReaderTime 0.000s | Percentage 100.00%
2018-03-18 23:22:44.321 [job-0] INFO  AbstractScheduler - Scheduler accomplished all tasks.
2018-03-18 23:22:44.322 [job-0] INFO  JobContainer - DataX Writer.Job [mysqlwriter] do post work.
2018-03-18 23:22:44.323 [job-0] INFO  JobContainer - DataX Reader.Job [mysqlreader] do post work.
2018-03-18 23:22:44.324 [job-0] INFO  JobContainer - DataX jobId [0] completed successfully.
2018-03-18 23:22:44.326 [job-0] INFO  HookInvoker - No hook invoked, because base dir not exists or is a file: /opt/datax/hook
2018-03-18 23:22:44.329 [job-0] INFO  JobContainer - 
         [total cpu info] => 
                averageCpu                     | maxDeltaCpu                    | minDeltaCpu                    
                -1.00%                         | -1.00%                         | -1.00%


         [total gc info] => 
                 NAME                 | totalGCCount       | maxDeltaGCCount    | minDeltaGCCount    | totalGCTime        | maxDeltaGCTime     | minDeltaGCTime     
                 PS MarkSweep         | 0                  | 0                  | 0                  | 0.000s             | 0.000s             | 0.000s             
                 PS Scavenge          | 0                  | 0                  | 0                  | 0.000s             | 0.000s             | 0.000s             

2018-03-18 23:22:44.329 [job-0] INFO  JobContainer - PerfTrace not enable!
2018-03-18 23:22:44.331 [job-0] INFO  StandAloneJobContainerCommunicator - Total 4 records, 63 bytes | Speed 6B/s, 0 records/s | Error 0 records, 0 bytes |  All Task WaitWriterTime 0.000s |  All Task WaitReaderTime 0.000s | Percentage 100.00%
2018-03-18 23:22:44.333 [job-0] INFO  JobContainer - 
任务启动时刻                    : 2018-03-18 23:22:33
任务结束时刻                    : 2018-03-18 23:22:44
任务总计耗时                    :                 11s
任务平均流量                    :                6B/s
记录写入速度                    :              0rec/s
读出记录总数                    :                   4
读写失败总数                    :                   0
相关推荐
©️2020 CSDN 皮肤主题: 撸撸猫 设计师:马嘣嘣 返回首页