版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sqh201030412/article/details/78064071
1.azkaban的安装
2.azkaban的几种使用
2.1 使用小Demo
#command
type=command
command=sh/home/hadoop/shell/say_hello.sh
shell脚本
#!/bin/sh
format="+%Y%m%d_%H:%M:%S"
now_date=`date$format`
echo$now_datehelloworld!>>/home/hadoop/logs/say_hello.log
2.2 依赖任务的Demo
运行的Job
#command
type=command
command=sh/home/hadoop/shell/say_hello.shA
#command
type=command
command=sh/home/hadoop/shell/say_hello.shB
#command
type=command
command=sh/home/hadoop/shell/say_hello.shC
dependencies=A,B
执行的脚本
#!/bin/sh
user_name=$1
format="+%Y%m%d_%H:%M:%S"
now_date=`date$format`
echo$user_name$now_datehelloworld!>>/home/hadoop/logs/say_hello.log
2.3 操作HDFS的Demo
#command
type=command
command=hadoopfs-mkdir/azkaban_demo
2.4 操作Hive
在HDFS中创建目录/aztest/hiveinput
上传一个用户名文件如下:
1,xiaoming
2,xiaohong
3,xiaofang
5,xiaozhang
azkaban执行Job文件
#command
type=command
command=/home/hadoop/app/hive/bin/hive-f'/home/hadoop/sql/create_demo_table.sql'
create_demo_table.sql 文件内容
usedefault;
droptableaztest;
createtableaztest(idint,namestring)rowformatdelimitedfieldsterminatedby',';
loaddatainpath'/aztest/hiveinput'intotableaztest;
createtableazresasselect*fromaztest;
insertoverwritedirectory'/aztest/hiveoutput'selectcount(1)fromaztest;
查看执行结果: