create table stu(id number(5),name VARCHAR(20),grade NUMBER(5),score NUMBER(5));
INSERT INTO STU VALUES(1,'李四',8,100);
INSERT INTO STU VALUES(2,'多多',9,115);
INSERT INTO STU VALUES(3,'熊安安',7,99);
INSERT INTO STU VALUES(4,'安琪',6,56);
INSERT INTO STU VALUES(5,'等等',4,88);
INSERT INTO STU VALUES(6,'小花',2,97);
create table if not exists stu(
id int,
name string,
grade int,
score int
)
stored as textfile;
{
"job": {
"setting": {
"speed": {
"byte": 1048576
},
"errorLimit": {
"record": 0,
"percentage": 0.02
}
},
"content": [
{
"reader": {
"name": "oraclereader",
"parameter": {
"column": ["id","name","grade","score"],
"connection": [
{
"jdbcUrl": ["jdbc:oracle:thin:@10.6.13.226:1521:orcl"],
"table": ["STU"]
}
],
"password": "123456",
"username": "SCOTT"
}
},
"writer": {
"name":"hdfswriter",
"parameter": {
"defaultFS":"hdfs://192.168.6.102:8020",
"fileType":"text",
"path":"/user/hive/warehouse/test_hive.db/stu",
"fileName":"stu",
"column":[
{"name":"id","type":"int"}
],
"writeMode":"append",
"fieldDelimiter":"\u0001",
"compress":"gzip"
}
}
}
]
}
}
//需要注意的是"fieldDelimiter":"\u0001" 如果是”\t”则hive中不能读取到数据,将会展示为空
python /opt/module/datax/bin/datax.py /opt/module/datax/bin/json_conf/student.json
(1)配置Oracle数据源
数据源:oracle
用户名:SCOTT
密码:123456
JDBCURL:10.6.13.25:1521/orcl
(2)配置Hive数据源
数据源:hive
用户名:atguigu
密码:123456
JDBCURL:192.168.6.102:10000/ods
(1)配置Reader
(2)配置Writer
(3)配置字段映射
(4)构建
(5)选择模板
(6)项目创建成功
(1)立即执行
(2)查看日志
(3)查看报错原因
(4)重新编辑任务
(5)存在问题
(6)再次运行&查看日志
(7)查看hive表中数据