用Oozie调度shell脚本操作ambari --- 以hiveserver为例

测试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标签不要忘记了.


   ${jobTracker}
   ${nameNode}
   hdfs://bigdata/user/username/oozie-oozi/restart_hiveserver2.sh
   /user/username/oozie-oozi/restart_hiveserver2.sh#restart_hiveserver2.sh
   

参考:

  • https://cwiki.apache.org/confluence/display/AMBARI/Restarting+host+components+via+the+API

你可能感兴趣的:(用Oozie调度shell脚本操作ambari --- 以hiveserver为例)