使用阿里云DataX完成数据同步

DataX

DataX 是阿里云 DataWorks 数据集成的开源版本,在阿里巴巴集团内被广泛使用的离线数据同步工具/平台。DataX 实现了包括 MySQL、Oracle、OceanBase、SqlServer、Postgre、HDFS、Hive、ADS、HBase、TableStore(OTS)、MaxCompute(ODPS)、Hologres、DRDS, databend 等各种异构数据源之间高效的数据同步功能。

官网:https://github.com/alibaba/DataX

环境准备

参考官网:https://github.com/alibaba/DataX/blob/master/userGuid.md

下载解压后

MongoDB同步数据至达梦数据库

新建xxx.json,写入如下内容

javascript 复制代码
  {
  "job": {
      "setting": {
          "speed": {
              "channel": 10
          }
      },
      "content": [
          {
              "reader": {
                  "name": "mongodbreader",
                  "parameter": {
                      "address": ["192.168.2.39:27017"],
                      "userName": "",
                      "userPassword": "",
                      "dbName": "ztcx_test",
                      "collectionName": "gps_driver_location_20230718",
                      "column": [
                          {
                              "name": "longitude",
                              "type": "Double"
                          },
                          {
                              "name": "latitude",
                              "type": "Double"
                          },
                          {
                              "name": "location_type",
                              "type": "int"
                          },
                          {
                              "name": "type",
                              "type": "int"
                          },
                          {
                              "name": "driver_id",
                              "type": "Long"
                          },
                          {
                              "name": "plate_no",
                              "type": "string"
                          },
                          {
                              "name": "create_date",
                              "type": "Date",
                          }
                      ]
                  }
              },
              "writer": {
                  "name": "rdbmswriter",
                  "parameter": {
                     "connection": [
                            {
                                "jdbcUrl": "jdbc:dm://192.168.2.27:5236/DATAX",
                                "table": [
                                    "DRIVER_LOCATION"
                                ]
                            }
                        ],
                        "username": "xxx",
                        "password": "****",
                        "table": "DRIVER_LOCATION",
                        "column": [
                           "longitude",
						   "latitude",
						   "location_type",
						   "type",
						   "driver_id",
						   "plate_no",
						   "create_date"
                        ],
                        "preSql": [
                            "delete from DRIVER_LOCATION;"
                        ]
                  }
              }
          }
      ]
  }
  }

配置文件属性,可参考

切换至bin目录,执行以下命令即可

bash 复制代码
python datax.py ./xxx.json
相关推荐
ClouGence9 小时前
Oracle 数据同步为什么会出现数据不一致?长事务是常被忽略的原因
数据库·后端·oracle
飞将11 小时前
从零实现数据库(2)——HashIndex + IndexManager
数据库
Nturmoils1 天前
订单列表慢查询,先看 WHERE、ORDER BY 和 LIMIT
数据库
渣波1 天前
拒绝 SQL 焦虑!手把手带你用 NestJS + Prisma + DTO 写出“防弹”级后端代码
javascript·数据库·后端
倔强的石头_3 天前
KingbaseES 新版MySQL 兼容版体验:旧版迁移 + 功能实测
数据库
倔强的石头_5 天前
《Kingbase护城河》——数据库存储空间全景探测与精细化瘦身实战
数据库
冬奇Lab6 天前
每日一个开源项目(第134篇):Zvec - 阿里开源的嵌入式向量数据库,向量搜索界的 SQLite
数据库·人工智能·llm
ClouGence6 天前
Oracle CDC 架构优化:从主库直连到 DataGuard 备库同步
数据库·后端·oracle
无响应de神6 天前
三、用户与权限管理
数据库·mysql
Inhand陈工7 天前
基于台达PLC与映翰通IG502的智慧水产养殖精准投喂与远程运维解决方案
运维·人工智能·物联网·阿里云·信息与通信