文章

Datax

需求是从Oracle中同步表到PostgreSQL中

直接贴上配置文件

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
    "job": {
        "setting": {
            "speed": {
                 "byte": 1048576000
            },
                "errorLimit": {
                "record": 0,
                "percentage": 0.02
            }
        },
        "content": [
            {
                "reader": {
                    "name": "oraclereader",
                    "parameter": {
                        "username": "yezi",
                        "password": "yezi2022@154",
                        "column": [
                            "mobile","url_code"
                        ],
                        "connection": [
                            {
                                "table": [
                                    "$tab1"
                                ],
                                "jdbcUrl": [
     "jdbc:oracle:thin:@192.168.1.3:1521:yezi"
                                ]
                            }
                        ]
                    }
                },
                "writer": {
                    "name": "postgresqlwriter",
                    "parameter": {
                        "username": "postgres",
                        "password": "1",
                        "column": [
                            "mobile1",
                            "url_code"
                        ],
                        "preSql": [
                            "truncate $tab2"
                        ],
                        "connection": [
                            {
                                "jdbcUrl": "jdbc:postgresql://192.168.1.165:5432/db",
                                "table": [
                                    "$tab2"
                                ]
                            }
                        ]
                    }
            }
        }
        ]
    }
}

其中 $tab1 $tab2 作为变量传入

启动参数

1
/usr/bin/python /data/soft/datax/bin/datax.py -p "-Dtab1='$1' -Dtab2='$2'" /data/soft/datax/bin/x.json

遇到的问题:

  1. ._drdsreader/plugin.json] 不存在
1
rm -rf /data/soft/datax/plugin/*/._*
本文由作者按照 CC BY 4.0 进行授权