#hivef.job
type=command
command=hive -f test.sql
#test.sql
use default;
drop table aztest;
create table aztest(id int,name string) row format delimited fields terminated by ",";
load data inpath '/home/lxl/b.txt' into table aztest;
create table azres as select * from aztest;
注意:因为azkaban是root用户安装的,所以在执行hivef.job文件时,里的command=su hdfs hive -f test.sql 需要写成这样,哈哈。
如果是root用户需要在hdfs配置中去掉权限,不然执行不了。 在HDFS配置页面,找到属性dfs.permissions,取消勾选即可。
1.先把把文件b.txt上传到hdfs服务器
/root/device-report
其中b.txt内容如下:
2,bb
3,cc
7,yy
9,pp
2.修改文件权限
3.放到hdfs用户目录下:
4.切换到hdfs用户下:
su hdfs
5.把b.txt上传到hdfs服务器上:
6.把test.sql,hivef打包zip文件
7.azkaban中创建计划项目,如下:
8.上传zip文件:
9.添加执行计划:
10.直接执行:
11.执行后显示如下:
12.看hive中是否有aztest和azres表
看是否都有数据:
完美,但是还是建议在hdfs上安装azkaban。
以下是切换到hdfs用户下执行创建表等,以后请按这样的格式进行执行job。
#hivef.job
type=command
command=sudo -u hdfs hive -f test.sql
#test.sql
use default;
drop table aztest;
create table aztest(id int,name string) row format delimited fields terminated by ",";
load data inpath '/home/lxl/b.txt' into table aztest;
create table azres as select * from aztest;