#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.修改文件权限
azkaban 执行hive语句
3.放到hdfs用户目录下:
 azkaban 执行hive语句azkaban 执行hive语句
4.切换到hdfs用户下:
     su hdfs
azkaban 执行hive语句
azkaban 执行hive语句
5.把b.txt上传到hdfs服务器上:
azkaban 执行hive语句
azkaban 执行hive语句
6.把test.sql,hivef打包zip文件
     azkaban 执行hive语句azkaban 执行hive语句
7.azkaban中创建计划项目,如下:
azkaban 执行hive语句
8.上传zip文件:
azkaban 执行hive语句
9.添加执行计划:
azkaban 执行hive语句

 

10.直接执行:
azkaban 执行hive语句

11.执行后显示如下:

azkaban 执行hive语句

 

 
 azkaban 执行hive语句

 

 
 
12.看hive中是否有aztest和azres表
azkaban 执行hive语句
azkaban 执行hive语句
看是否都有数据:
azkaban 执行hive语句
azkaban 执行hive语句
完美,但是还是建议在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;

 

相关文章:

  • 2022-12-23
  • 2021-08-02
  • 2021-09-26
  • 2021-10-11
  • 2021-11-26
  • 2021-06-05
  • 2021-07-22
猜你喜欢
  • 2021-06-23
  • 2021-04-10
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
相关资源
相似解决方案