当前位置:网站首页>Data_web(八)mysql增量同步到mongodb
Data_web(八)mysql增量同步到mongodb
2022-08-03 21:36:00 【ReadMeFrist】
1.mongdb连接
连接方式如下(重要!!!!,账号密码必须建立在db下面,如果默认再admin下面,导致无法切换库,连接报错)
2.mysql增量同步到mongodb的json如下,(可以参考先前文章mysql增量时间同步方式)
{
"job": {
"setting": {
"speed": {
"channel": 3,
"byte": 1048576
},
"errorLimit": {
"record": 0,
"percentage": 0.02
}
},
"content": [
{
"reader": {
"name": "mysqlreader",
"parameter": {
"username": "123",
"password": "123",
"connection": [
{
"jdbcUrl": [
"jdbc:mysql://192.168.1.101:3306/test"
],
"querySql": [
"SELECT 'test'as source,(CASE when gateway_id=9 then 'test' ELSE 'tnc' end) as app_code,target ,target_account_id as account_id, null as user_name, sms_content as content, send_time ,send_id as outer_id FROM qfc_mcs_send_mass_info where sms_type = '3' and status in (3,4) and send_time >= FROM_UNIXTIME(${lastTime}) and send_time < FROM_UNIXTIME(${currentTime});"
]
}
]
}
},
"writer": {
"name": "mongodbwriter",
"parameter": {
"address": [
"192.168.1.100:27017"
],
"userName": "username",
"userPassword": "password",
"dbName": "DBname",
"collectionName": "message_send_info",
"column": [
{
"name": "sourceSystem",
"type": "String"
},
{
"name": "app_code",
"type": "String"
},
{
"name": "target",
"type": "String"
},
{
"name": "account_id",
"type": "Long"
},
{
"name": "user_name",
"type": "String"
},
{
"name": "content",
"type": "String"
},
{
"name": "send_time",
"type": "Date"
},
{
"name": "outer_id",
"type": "Long"
}
],
"upsertInfo": {
"isUpsert": false,
"upsertKey": ""
}
}
}
}
]
}
}
如果需要更新isUpsert改写true upsertKey为更新的字段
3.字段参考
DataX 内部类型 | MongoDB 数据类型 |
---|---|
Long | int, Long |
Doubl | double |
String | string, array |
Date | date |
Bytes | bytes |
边栏推荐
猜你喜欢
随机推荐
2022-8-3 第七组 潘堂智 锁、多线程
CAS:122567-66-2_DSPE-生物素_DSPE-Biotin
XSS线上靶场---haozi
DO280管理和监控OpenShift平台--资源限制
CAS:908007-17-0_Biotin-azide_Biotin azide
PyCharm function automatically add comments without parameters
2022/08/03 学习笔记 (day23)多线程(补充)
C. awoo‘s Favorite Problem--Educational Codeforces Round 130 (Rated for Div. 2)
函数,递归以及dom简单操作
FVCOM 3D Numerical Simulation of Hydrodynamics, Water Exchange, Dispersion and Transport of Oil Spills丨FVCOM Model Watershed, Numerical Simulation Method of Marine Water Environment
分分钟教你读取 resources 目录下的文件路径
LitJson报错记录
现网设备兼容SRv6网络演进
CAS:153162-70-0_N-BOC-6-生物素酰氨基己胺
函数,递归以及dom简单操作
1 秒完成授权,Authing 全新上线一键登录功能
382. Linked List Random Node
A. Color the Picture- Codeforces Round #810 (Div. 1)
码率vs.分辨率,哪一个更重要?
XSS online shooting range---Warmups