• 从Oracle中读取数据存到MySQL

    1)MySQL中创建表

    [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 |
    
    +------+----------+

     

  •  
  • 转自“http://t.zoukankan.com/LIAOBO-p-13666789.html”