datax数据传输实践

1,参考文档

https://zhuanlan.zhihu.com/p/515541286

https://github.com/alibaba/DataX/blob/master/introduction.md

https://github.com/alibaba/DataX

2,sqlserver_2_clickhouse datax脚本

(*)注意这里:sqlserverreader,clickhousewriter 是固定写法

{
  "job": {
    "setting": {
      "speed": {
        "channel":1
      }
    },
    "content": [
      {
        "reader": {
          "name": "sqlserverreader",
          "parameter": {
            "username": "root",
            "password": "123123",
            "connection": [
              {
                "querySql": [
                  "select id,user_name,money from xiaoming.dbo.zy_user;"
                ],
                "jdbcUrl": [
                  "jdbc:sqlserver://xxx.rds.aliyuncs.com:3433"
                ]
              }
            ]
          }
        },
        "writer": {
          "name": "clickhousewriter",
          "parameter": {
            "writeMode": "insert",
            "username": "default",
            "password": "123123",
            "column": [
              "id",
              "user_name",
              "money"
            ],
            "session": [
              "set session sql_mode='ANSI'"
            ],
            "preSql": [
              "truncate table bigdata.ods_zy_user;"
            ],
            "connection": [
              {
                "jdbcUrl":"jdbc:clickhouse://localhost:8123/bigdata?useUnicode=true&characterEncoding=utf-8",
                "table": [
                  "ods_zy_user"
                ]
              }
            ]
          }
        }
      }
    ]
  }
}
{
"job": {
    "setting": {
      "speed": {
        "channel": 1
      }
    },
    "content": [
      {
        "reader": {
          "name": "sqlserverreader",
          "parameter": {
            "username": "your_db_name",
            "password": "your_pwd",
            "column": [
              "[FCUSTID]",
              "[FNAME]",
              "[FDocumentStatus]",
              "[FForbidStatus]",
              "[FCreateOrgId]",
              "[FUseOrgId]",
              "[FCreateDate]",
              "[FModifyDate]",
              "[F_QFES_Text8]",
              "[F_QFES_Text10]",
              "[FDescription]",
              "[C1FDATAVALUE]",
              "[C2FDATAVALUE]",
              "[C3FDATAVALUE]",
              "[FNUMBER]"
            ],
            "splitPk": "sale_id",
            "connection": [
              {
                "table": [
                  "your_tabname"
                ],
                "jdbcUrl": [
                  "jdbc:sqlserver://localhost:3433;DatabaseName=xxdbname"
                ]
              }
            ]
          }
        },
        "writer": {
          "name": "clickhousewriter",
          "parameter": {
            "username": "root",
            "password": "123123",
            "column": [
              "fcustid",
              "fname",
              "fdocumentstatus",
              "forbidstatus",
              "fcreate_orgid",
              "fuser_orgid",
              "fcreate_date",
              "fmodify_date",
              "f_qfes_text8",
              "f_qfes_text10",
              "fdescription",
              "c1_fdata_value",
              "c2_fdata_value",
              "c3_fdata_value",
              "fnumber"
            ],
            "connection": [
              {
                "table": [
                  "your_table_name"
                ],
                "jdbcUrl": "jdbc:clickhouse://localhost:8123/table_name"
              }
            ]
          }
        }
      }
    ]
  }
}

3,datax json格式脚本运行

# Linux运行指令
cd /opt/datax/bin
python datax.py -r streamreader -w streamwriter
python datax/bin/datax.py ./sqlserver_2_ch.json
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用DataX进行数据传输,你需要进行以下步骤: 1. 学习DataX数据源配置方式。这将帮助你了解如何配置你的数据源。 2. 下载DataX安装包到服务器并解压。确保你的服务器上已经安装了Python。 3. 在解压后的DataX目录中,通过运行以下命令来测试运行DataX:python <datax_home>/bin/datax.py <datax_home>/job/job.json。这将运行一个示例作业。 4. 为了配置SQL进行数据传输,你可以使用以下命令来查看DataX的配置文件模板:python bin/datax.py -r mysqlreader -w hdfswriter。这个命令将展示了如何配置MySQL作为取器和HDFS作为入器。 5. 根据你的具体需求,修改配置文件模板中的相关配置,如数据库连接信息、表名、字段映射等。 6. 运行DataX命令,使用你修改后的配置文件:python <datax_home>/bin/datax.py <your_job_config_file>.json。 通过以上步骤,你就可以使用DataX进行SQL配置的数据传输了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [DataX数据迁移入门](https://blog.csdn.net/weixin_42660202/article/details/129329761)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值