使用阿里云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,写入如下内容

  {
  "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目录,执行以下命令即可

python datax.py ./xxx.json

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值