当前位置:网站首页>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 |
边栏推荐
猜你喜欢
随机推荐
『百日百题 · 基础篇』备战面试,坚持刷题 第四话——循环语句!
ValidationError: Progress Plugin Invalid Options
2022年全国职业院校技能大赛网络安全 B模块 任务十windows操作系统渗透测试 国赛原题
解决npm -v查看npm版本出现npm WARN config global `--global`, `--local` are deprecated. Use `--location报错
[kali-vulnerability exploitation] (3.2) Metasploit basics (on): basic knowledge
上课笔记(6)(1)——#629. 表达式括号匹配(stack)
小朋友学C语言(1):Hello World
Engineering Effectiveness Governance for Agile Delivery
Zero trust, which has been popular for more than ten years, why can't it be implemented?
详解虚拟机!京东大佬出品 HotSpot VM 源码剖析笔记(附完整源码)
idea2021配置svn报错Cannot run program “svn“ (in directory “xxx“):CreateProcess error=2,系统找不到指定的文件
385. Mini Parser
XSS testing
超级实用网站+公众号合集
376. Wiggle Subsequence
太香了! 阿里 Redis 速成笔记, 从头到尾全是精华!
XSS practice - cycle and two cycle problem at a time
Diazo Biotin-PEG3-DBCO|重氮化合物修饰生物素-三聚乙二醇-二苯并环辛炔
嵌入式开发:嵌入式基础——代码和数据空间揭秘
Nacos配置文件管理、微服务获取Nacos配置文件