zoukankan      html  css  js  c++  java
  • datax踩坑

    datax使用心得:

    1.下载路径:https://github.com/alibaba/DataX 在页面中【Quick Start】--->【Download DataX下载地址】进行下载。下载后的包名:datax.tar.gz。解压后{datax}目录下有{bin conf job lib log log_perf plugin script tmp}几个目录。

     2.由于现在用的 python 版本大多为 python3 ,所以把 [datax_hoem]/bin 目录下的三个py文件修改成了符合 python3 语法要求的文件,执行也没报错,修改后的文件,如需要可下载替换:https://github.com/TwoThreeWang/DataX_Python3

    3.建立csv到mysql的json文件(命名为test.json)

    {
         "job": {
              "setting": {
                  "speed": {
                      "channel": 2
                  }
             },
              "content": [
                  {
                    "reader": {
                         "name": "txtfilereader",
                         "parameter": {
                            "path": ["D:/a.csv"],
                             "encoding": "UTF-8",
                             "column": [
                                 {
                                     "index": 0,
                                     "type": "string"
                                 },
                                 {
                                     "index": 1,
                                     "type": "string"
                                 }
                             ],
                             "fieldDelimiter": ";",
                             "skipHeader": "False"
                        }
                     },
                     
                    "writer": {
     
                        "name": "mysqlwriter",
     
                         "parameter": {
     
                           "writeMode": "insert",
     
                            "username": "root",
     
                             "password": "ljm",
     
                            "column": [
    
                                "http",
     
                                 "https"
     
                             ],
     
                             "session": [],
     
                             "connection": [
     
                                 {
     
                                     "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/big_shuju?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8",
     
                                     "table": ["test"]
    
                                 }
     
                             ]
     
                         }
     
                     }                 
                    
                 }
             ]
         }
     }
    

      注:密码不能为空,如果mysql连接密码是空,请提前修改密码。

    4.启动datax的执行命令:python datax.py D:DataX-json est.json(注:后面的是json文件路径,控制台运行时提前切换到datax/bin目录)

    5.控制台出现乱码:直接输入CHCP 65001即可

     测试截图:

     

  • 相关阅读:
    ubuntu 16.04 网络配置之虚拟网卡的配置
    rabbitmq集群节点操作
    Ubuntu system zabbix-server-3.x install documentation
    PS RSS
    proxy_set_header设置Host为$proxy_host,$host与$local_host的区别
    centos 7 free 字段含义
    Linux atop 监控系统状态
    谨慎调整内核参数:vm.min_free_kbytes
    nginx反向代理http与https两种协议配置简述
    Python 获取以毫秒为单位的时间戳
  • 原文地址:https://www.cnblogs.com/ljm-zsy/p/12391406.html
Copyright © 2011-2022 走看看