DataX將MySql資料庫資料同步到Oracle資料庫

杜子烟發表於2024-05-16
1.下載DataX並解壓(本地環境安裝有python)
DataX/userGuid.md at master · alibaba/DataX (github.com)

job資料夾下存放資料同步的json指令碼

{
    "job": {
        "setting": {
            "speed": {
                "channel": 1
            }
        },
        "content": [
            {
                "reader": {
                    "name": "mysqlreader",
                    "parameter": {
                        "username": "${readUsername}",
                        "password": "${readPassword}",
                        "column": [
                            "CreateTime","Id","OrderNum"
                        ],
                        "connection": [
                            {
                                "table": [
                                    "table1"
                                ],
                                "jdbcUrl": [
                                  "jdbc:mysql://${readJdbcUrl}?useUnicode=true&characterEncoding=utf-8&useSSL=false"
                                ]
                            }
                        ]
                    }
                },
                "writer": {
                    "name": "oraclewriter",
                    "parameter": {
                        "username": "${writeUsername}",
                        "password": "${writePassword}",
                        "column": [
                            "CREATETIME","ID","ORDER_NUM"
                        ],
                        "connection": [
                            {
                                "jdbcUrl": "jdbc:oracle:thin:@${writeJdbcUrl}",
                                "table": [
                                    "Table1"
                                ]
                            }
                        ]
                    }
                }
            }
        ]
    }
}




python D:\datax\bin\datax.py D:\datax\table1_job.json  -p "-DreadJdbcUrl=127.0.0.1:3306/testdb -DreadUsername=root -DreadPassword=123456 -DwriteJdbcUrl=127.0.0.1:1521:TestDB -DwriteUsername=yonghuming -DwritePassword=mima"

{
    "job": {
        "setting": {
            "speed": {
                "channel": 1,
                "byte": 1048576
            },
            "errorLimit": {
                "record": 0,
                "percentage": 0.02
            }
        },
        "content": [
            {
                "reader": {
                    "name": "mysqlreader",
                    "parameter": {
                        "username": "root",
                        "password": "123456",
                        "column": [
                            "Id"
                        ],
                        "where": "",
                        "splitPk": "",
                        "connection": [
                            {
                                "table": [
                                    "testtb"
                                ],
                                "jdbcUrl": [
                                    "jdbc:mysql://127.0.0.1:3306/testdb"
                                ]
                            }
                        ]
                    }
                },
                "writer": {
                    "name": "oraclewriter",
                    "parameter": {
                        "username": "yonghuming",
                        "password": "mima",
                        "writeMode": "insert",
                        "column": [
                            "Id"
                        ],
                        "connection": [
                            {
                                "table": [
                                    "testtb1"
                                ],
                                "jdbcUrl": "jdbc:oracle:thin:127.0.0.1:1521:TestDB"
                            }
                        ]
                    }
                }
            }
        ]
    }
}
python D:\datax\bin\datax.py D:\datax\table1_job.json
 

相關文章