当前位置:网站首页>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 |
边栏推荐
猜你喜欢
『百日百题 · 基础篇』备战面试,坚持刷题 第四话——循环语句!
开源一夏 |如何优化线上服务器
小朋友学C语言(3):整数、浮点数、字符
《QDebug 2022年7月》
6. XML
基于支持向量机的网络⼊侵检测系统的全面调查和分类
XSS online shooting range---prompt
[kali-vulnerability scanning] (2.1) Nessus lifts IP restrictions, scans quickly without results, and plugins are deleted (middle)
XSS practice - cycle and two cycle problem at a time
【kali-漏洞扫描】(2.1)Nessus下载安装(上)
随机推荐
跨端开发技术储备记录
1 秒完成授权,Authing 全新上线一键登录功能
False label aggregation
软考系统分析师备考经验分享:论持久战
C. Keshi Is Throwing a Party- Codeforces Global Round 17
IO thread process -> thread synchronization mutual exclusion mechanism -> day6
dataframe 多层索引 更换索引 df.swaplevel(axis=1)
[3D检测系列-PV-RCNN] PV-RCNN论文详解、PV-RCNN代码复现、包含官网PV-RCNN预训练权重及报错问题
卷起来!阿里高工携 18 位高级架构师耗时 57 天整合的 1658 页面试总结
一文带你了解软件测试是干什么的?薪资高不高?0基础怎么学?
B. Paranoid String
史兴国对谈于佳宁:从经济模式到落地应用,Web3的中国之路怎么走?
Soft exam system analysts note experience sharing: theory of protracted war
PyCharm function automatically add comments without parameters
软件测试人员必备的60个测试工具清单,建议收藏一波~
分分钟教你读取 resources 目录下的文件路径
【历史上的今天】8 月 3 日:微软研究院的创始人诞生;陌陌正式上线;苹果发布 Newton OS
Five Steps to Detect and Control Shadow IT
YOLO之父宣布退出CV界,坦言无法忽视自己工作带来的负面影响
IO线程进程->线程同步互斥机制->day6