使用dataX-stream2stream/stream2mysql/mysql2mysql/mysql2stream

yandao發表於2020-10-28

stream2stream

{
  "job": {
    "content": [
      {
        "reader": {
          "name": "streamreader",
          "parameter": {
            "sliceRecordCount": 5,
            "column": [
              {
                "type": "long",
                "value": "10"
              },
              {
                "type": "string",
                "value": "hello, test-DataX"
              }
            ]
          }
        },
        "writer": {
          "name": "streamwriter",
          "parameter": {
            "encoding": "UTF-8",
            "print": true
          }
        }
      }
    ],
    "setting": {
      "speed": {
        "channel": 5
       }
    }
  }
}```

#### stream2mysql
{
    "job": {
        "setting": {
            "speed": {
                "channel": 1
            }
        },
        "content": [
            {
                 "reader": {
                    "name": "streamreader",
                    "parameter": {
                        "column" : [
                            {
                                "value": "DataX",
                                "type": "string"
                            }
                        ],
                        "sliceRecordCount": 1000
                    }
                },
                "writer": {
                    "name": "mysqlwriter",
                    "parameter": {
                        "writeMode": "insert",
                        "username": "root",
                        "password": "APIB9hRP",
                        "column": [
                            "key_value",
                        ],
                        "session": [
                        	"set session sql_mode='ANSI'"
                        ],
                        "preSql": [
                            "delete from datax_mysqlwriter_perf_00"
                        ],
                        "connection": [
                            {
                                "jdbcUrl": "jdbc:mysql://localhost:3306/ssm?serverTimezone=UTC&useUnicode=true&characterEncoding=gbk",
                                "table": [
                                    "datax_mysqlwriter_perf_00"
                                ]
                            }
                        ]
                    }
                }
            }
        ]
    }
}
##### datax_mysqlwriter_perf_00

```java
CREATE TABLE `datax_mysqlwriter_perf_00` (
`biz_order_id` bigint(20) NOT NULL AUTO_INCREMENT  COMMENT 'id',
`key_value` varchar(4000) NOT NULL COMMENT 'Key-value的內容',
`gmt_create` datetime NOT NULL COMMENT '建立時間',
`gmt_modified` datetime NOT NULL COMMENT '修改時間',
`attribute_cc` int(11) DEFAULT NULL COMMENT '防止併發修改的標誌',
`value_type` int(11) NOT NULL DEFAULT '0' COMMENT '型別',
`buyer_id` bigint(20) DEFAULT NULL COMMENT 'buyerid',
`seller_id` bigint(20) DEFAULT NULL COMMENT 'seller_id',
PRIMARY KEY (`biz_order_id`,`value_type`),
KEY `idx_biz_vertical_gmtmodified` (`gmt_modified`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='datax perf test';

mysql2mysql

{
    "job": {
        "setting": {
            "speed": {
                "channel": 3
            },
            "errorLimit": {
                "record": 0,
                "percentage": 0.02
            }
        },
        "content": [{
            "reader": {
                "name": "mysqlreader",
                "parameter": {
                    "username": "root",
                    "password": "APIB9hRP",
                    "column": [
                        "id",
                        "name",
			"pid"
                    ],
                    "splitPk": "id",
                    "connection": [{
                        "table": [
                            "menu"
                        ],
                        "jdbcUrl": [
                            "jdbc:mysql://localhost:3306/ssm?serverTimezone=UTC"
                        ]
                    }]
                }
            },
            "writer": {
                "name": "mysqlwriter",
                "parameter": {
                    "writeMode": "insert",
                    "username": "root",
                    "password": "APIB9hRP",
                    "column": [
		        "id",
                        "name",
			"pid"
                    ],
                    "session": [
                        "set session sql_mode='ANSI'"
                    ],
                    "preSql": [
                        "delete from menu_test"
                    ],
                    "connection": [{
                        "table": [
                            "menu_test"
                        ],
                        "jdbcUrl": "jdbc:mysql://localhost:3306/ssm?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8"
                    }]
                }
            }
        }]
    }
}
table menu & manu_test

在這裡插入圖片描述
在這裡插入圖片描述

mysql2stream

{
    "job": {
        "setting": {
            "speed": {
                "channel": 3
            },
            "errorLimit": {
                "record": 0,
                "percentage": 0.02
            }
        },
        "content": [{
            "reader": {
                "name": "mysqlreader",
                "parameter": {
                    "username": "root",
                    "password": "APIB9hRP",
                    "column": [
                        "id",
                        "name",
			"pid"
                    ],
                    "splitPk": "id",
                    "connection": [{
                        "table": [
                            "menu"
                        ],
                        "jdbcUrl": [
                            "jdbc:mysql://localhost:3306/ssm?serverTimezone=UTC"
                        ]
                    }]
                }
            },
            "writer": {
                "name": "streamwriter",
                "parameter": {
                    "print": true
                }
            }
        }]
    }
}

相關文章