使用阿里云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
相关推荐
期待のcode7 小时前
MyBatisX插件
java·数据库·后端·mybatis·springboot
安审若无9 小时前
oracel迁移数据文件至其他目录操作步骤
数据库
sunxunyong9 小时前
doris运维命令
java·运维·数据库
小鸡吃米…10 小时前
Python PyQt6教程七-控件
数据库·python
忍冬行者10 小时前
清理三主三从redis集群的过期key和键值超过10M的key
数据库·redis·缓存
TimberWill10 小时前
使用Redis队列优化内存队列
数据库·redis·缓存
Knight_AL11 小时前
MySQL 中 UPDATE 语句的执行过程全解析
数据库·mysql
yngsqq11 小时前
兰顿蚂蚁——CAD二次开发
数据库
梁萌12 小时前
ShardingSphere分库分表实战
数据库·mysql·实战·shardingsphere·分库分表
川石课堂软件测试13 小时前
Mysql中触发器使用详详详详详解~
数据库·redis·功能测试·mysql·oracle·单元测试·自动化