如何确定配置更改后要重新启动的服务?

时间:2018-02-22 23:25:04

标签: ibm-cloud analytics-engine

我需要使用Ambari API对我的群集进行一些更改。进行更改后,我使用以下代码重新启动所有服务:

echo "stop and Start Services"

curl -k -v --user $AMBARI_USER:$AMBARI_PASSWORD -H "X-Requested-By: ambari" -i -X PUT -d '{"RequestInfo": {"context": "Stop All Services via REST"}, "ServiceInfo": {"state":"INSTALLED"}}' https://$AMBARI_HOST:$AMBARI_PORT/api/v1/clusters/$CLUSTER_NAME/services

sleep 200

curl -k -v --user $AMBARI_USER:$AMBARI_PASSWORD -H "X-Requested-By: ambari" -i -X PUT -d '{"RequestInfo": {"context": "Start All Services via REST"}, "ServiceInfo":{"state":"STARTED"}}' https://$AMBARI_HOST:$AMBARI_PORT/api/v1/clusters/$CLUSTER_NAME/services

sleep 700

这似乎非常重。有没有办法只重新启动需要重启的服务?

1 个答案:

答案 0 :(得分:0)

一种选择是使用此选项仅重新启动因重新配置而需要重新启动的服务:

curl -v --user $AMBARI_USER:$AMBARI_PASSWORD -H "X-Requested-By: ambari" -i -X POST -d '{ "RequestInfo": {"command": "RESTART","context": "Restart all required services","operation_level": "host_component"}, "Requests/resource_filters": [{"hosts_predicate": "HostRoles/stale_configs=true" }] }' https://$AMBARI_HOST:$AMBARI_PORT/api/v1/clusters/$CLUSTER_NAME/requests

检查上述命令的状态:

curl -v --user $AMBARI_USER:$AMBARI_PASSWORD -H "X-Requested-By: ambari" -X GET https://$AMBARI_HOST:$AMBARI_PORT/api/v1/clusters/$CLUSTER_NAME/requests/132