Oracle中读取数据存到MySQL

1MySQL中创建表

[oracle@hadoop102 ~]$ mysql -uroot -p000000

mysql> create database oracle;

mysql> use oracle;

mysql> create table student(id int,name varchar(20));

2)编写datax配置文件

[oracle@hadoop102 ~]$ vim /opt/module/datax/job/oracle2mysql.json

 

{

    "job": {

        "content": [

            {

                "reader": {

                    "name": "oraclereader",

                    "parameter": {

                        "column": ["*"],

                        "connection": [

                            {

                                "jdbcUrl": ["jdbc:oracle:thin:@hadoop102:1521:orcl"],

                                "table": ["student"]

                            }

                        ],

                        "password": "000000",

                        "username": "jason"

                    }

                },

                "writer": {

                    "name": "mysqlwriter",

                    "parameter": {

                        "column": ["*"],

                        "connection": [

                            {

                                "jdbcUrl": "jdbc:mysql://hadoop102:3306/oracle",

                                "table": ["student"]

                            }

                        ],

                        "password": "000000",

                        "username": "root",

                        "writeMode": "insert"

                    }

                }

            }

        ],

        "setting": {

            "speed": {

                "channel": "1"

            }

        }

    }

}

3)执行命令

 

[oracle@hadoop102 ~]$ /opt/module/datax/bin/datax.py /opt/module/datax/job/oracle2mysql.json

 

查看结果:

mysql> select * from student;

+------+----------+

| id   | name     |

+------+----------+

|    1 | zhangsan |

+------+----------+

 

posted on 2020-09-14 15:07  架构艺术  阅读(632)  评论(0编辑  收藏  举报