CentOS搭建:DataX

12/31/2023 Linux

目录


参考:


# CentOS搭建:DataX

# 环境依赖

软件/系统 版本 包名 备注
Linux 7(64) CentOS
JDK8 8+
Python 2+
DataX datax.tar.gz 官网下载 (opens new window)

# 解压缩包

cd /opt/
mkdir datax
mv datax.tar.gz datax/
cd datax/
ll
tar -zxvf datax.tar.gz
1
2
3
4
5
6

# 运行自检脚本

cd  /opt/datax/datax/bin
python datax.py ../job/job.json
1
2

报错处理:

[main] WARN  ConfigParser - 插件[streamreader,streamwriter]加载失败,1s后重试... Exception:Code:[Common-00], Describe:[您提供的配置文件存在错误信息,请检查您的作业配置 .]
1

如果需要这个错误,请进入plugin/reader 和 plugin/writer,使用ls -al 命令查看目录,删除里面所有以点开头的文件

cd  /opt/datax/datax/plugin/reader/
rm -rf ./._*
cd  /opt/datax/datax/plugin/writer/
rm -rf ./._*
1
2
3
4

再次执行自检脚本

# 编写启动测试文件

查看配置模板:

cd  /opt/datax/datax/bin
python datax.py -r streamreader -w streamwriter
1
2
cd  /opt/datax/datax/bin
vim stream2stream.json
1
2
{
  "job": {
    "content": [
      {
        "reader": {
          "name": "streamreader",
          "parameter": {
            "sliceRecordCount": 10,
            "column": [
              {
                "type": "long",
                "value": "10"
              },
              {
                "type": "string",
                "value": "hello,你好,世界-DataX"
              }
            ]
          }
        },
        "writer": {
          "name": "streamwriter",
          "parameter": {
            "encoding": "UTF-8",
            "print": true
          }
        }
      }
    ],
    "setting": {
      "speed": {
        "channel": 5
       }
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

# 启动DataX

cd  /opt/datax/datax/bin
python datax.py ./stream2stream.json 
1
2

如下表示成功:

631a5d284c1041648810a47f54d3c1ea

上次更新时间: 9/25/2024, 1:19:15 AM