创建Doris表
CREATE TABLE `mars_micro_user_events` (
`id` bigint,
`user_id` bigint DEFAULT NULL ,
`group_type` int DEFAULT NULL,
`group_id` int DEFAULT NULL,
`event_type` varchar(45) DEFAULT NULL,
`event_name` varchar(45) DEFAULT NULL,
`event_count` int DEFAULT NULL,
`event_time` bigint DEFAULT NULL,
`created_time` bigint DEFAULT NULL,
`updated_time` bigint DEFAULT NULL
) ENGINE=OLAP
DUPLICATE KEY(id)
COMMENT "OLAP"
DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES (
"replication_num" = "3"
);
DataX 配置JSON文件 (mysqlToDoris.json)
{
"core":{
"transport": {
"channel": {
"speed": {
"byte": 104857600,
"record": 200000
}
}
}
},
"job": {
"setting": {
"speed": {
"channel": 1
},
"errorLimit": {
"record": 0,
"percentage": 0
}
},
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"username": "dev",
"password": "123456",
"connection": [
{
"jdbcUrl": [
"jdbc:mysql://mysql.xxx.cn:3306/event_db"
],
"querySql": [
"select id,user_id,group_type,group_id,event_type,event_name,event_time,created_time,updated_time from eventc_db.user_events where event_time>=${StartTime} and event_time<${EndTime};"
]
}
]
}
},
"writer": {
"name": "doriswriter",
"parameter": {
"username": "root",
"password": "",
"database": "event_db",
"table": "events",
"column": [ "id", "group_type","group_id","event_type","event_name","event_time","created_time","updated_time"],
"preSql": [],
"postSql": [],
"jdbcUrl": "jdbc:mysql://cdh3:9030/",
"feLoadUrl": ["cdh3:8030"],
"beLoadUrl": ["cdh1:8044", "cdh2:8044", "cdh3:8044"],
"loadProps": {
},
"maxBatchRows" : 200000,
"maxBatchByteSize" : 104857600,
"lineDelimiter": "\n"
}
}
}
]
}
}
执行任务
python /opt/app/datax/bin/datax.py /opt/app/datax/bin/mysqlToDoris.json -p "-DStartTime=1546272000000 -DEndTime=1650791448000"