使用阿里云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
相关推荐
AAA修煤气灶刘哥7 小时前
后端人速藏!数据库PD建模避坑指南
数据库·后端·mysql
RestCloud11 小时前
揭秘 CDC 技术:让数据库同步快人一步
数据库·api
得物技术14 小时前
MySQL单表为何别超2000万行?揭秘B+树与16KB页的生死博弈|得物技术
数据库·后端·mysql
可涵不会debug18 小时前
【IoTDB】时序数据库选型指南:工业大数据场景下的技术突围
数据库·时序数据库
ByteBlossom18 小时前
MySQL 面试场景题之如何处理 BLOB 和CLOB 数据类型?
数据库·mysql·面试
麦兜*19 小时前
MongoDB Atlas 云数据库实战:从零搭建全球多节点集群
java·数据库·spring boot·mongodb·spring·spring cloud
Slaughter信仰19 小时前
深入理解Java虚拟机:JVM高级特性与最佳实践(第3版)第十章知识点问答(10题)
java·jvm·数据库
麦兜*19 小时前
MongoDB 在物联网(IoT)中的应用:海量时序数据处理方案
java·数据库·spring boot·物联网·mongodb·spring
-Xie-19 小时前
Mysql杂志(十六)——缓存池
数据库·mysql·缓存