用Oozie调度shell脚本操作ambari --- 以hiv
2018-12-18 本文已影响0人
海边的贝壳林
测试oozie调用shell的可行性, 这里我以调用钉钉群机器人的方式进行测试.
curl -H 'Content-Type: application/json' -X POST -d '{"msgtype": "text", "text": {"content": "我就是我, 是不一样的烟火"}}' https://oapi.dingtalk.com/robot/send?access_token=fccxxxxxxxxx463215a59eebeb412d3c2b5ed
使用ambari的web api重启hiveserver. 这里我重启了两个host中的HiveServer2.
curl -u username:passwd -H 'X-Requested-By: ambari' -X POST -d '{
"RequestInfo":{
"command":"RESTART",
"context":"Restart HiveServer2 on client01/02.bigdata.hbh.local",
"operation_level":{
"level":"HOST",
"cluster_name":"bigdata"
}
},
"Requests/resource_filters":[
{
"service_name":"HIVE",
"component_name":"HIVE_SERVER",
"hosts":"client01.bigdata.hbh.local"
},
{
"service_name":"HIVE",
"component_name":"HIVE_SERVER",
"hosts":"client02.bigdata.hbh.local"
}
]
}' http://client02.bigdata.hbh.local:8080/api/v1/clusters/bigdata/requests
在action中写入下面的xml描述. 这里注意file标签不要忘记了.
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<exec>hdfs://bigdata/user/username/oozie-oozi/restart_hiveserver2.sh</exec>
<file>/user/username/oozie-oozi/restart_hiveserver2.sh#restart_hiveserver2.sh</file>
<capture-output/>
</shell>
参考: