azkaban 執行hive語句


#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;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM