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

How to determine which services to restart after a configuration change?

我需要使用 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

这似乎很重量级。有没有办法只重启需要重启的服务?

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

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