Ambari-Rest-API 发表于 2016-10-11 | 分类于 BigData | | 本文总阅读量 次 本文记录了一些Ambari常用的Rest API。 查看服务状态1234查看所有服务信息:(注意服务名大写)curl -u admin:$PASSWORD -H "X-Requested-By: ambari" -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services查看某个服务的信息:curl -u admin:$PASSWORD -H "X-Requested-By: ambari" -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$SERVICE_NAME 停止服务1curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Stop Service"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$SERVICE_NAME 删除服务1234删除某服务curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X DELETE http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$SERVICE_NAME删除某节点上服务组件:curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X DELETE http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/$HOST_NAME/host_components/$COMPONENT_NAME 添加服务12添加某个服务的组件:curl -u admin:$PASSWORD -H "X-Requested-By:ambari" -X POST "http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/$HOST_NAME/host_components/$COMPONENT_NAME" 获取服务在节点信息1curl -u admin:$PASSWORD -H "X-Requested-By: ambari" -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/$SERVICE_NAME/components/$COMPONENT_NAME 2>/dev/null |grep "host_name" 启动所有服务1curl -u admin:$PASSWORD -i -H "X-Requested-By:ambari" -X PUT -d '{"ServiceInfo": {"state" : "STARTED"}}' http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services 欢迎您扫一扫上面的微信公众号,订阅我的博客!