Support Questions

Find answers, ask questions, and share your expertise

How to restart/refresh client config on all the hosts using Ambari API

avatar
Expert Contributor

Below article shows how to restart clients on Specific host. 

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

Is there any way we can perform the same on all the hosts in the cluster at one time.

Thank you in advance.

1 ACCEPTED SOLUTION

avatar
Expert Contributor

I was able to figure out with the help of below community article.
https://community.cloudera.com/t5/Community-Articles/How-to-install-all-clients-on-all-nodes-in-your...

cluster/ta-p/246821

script.sh
---------
curl -s -u admin:admin http://ambari:8080/api/v1/hosts|grep host_name|sed -n 's/.*"host_name" : "\([^\"]*\)".*/\1/p'>hostcluster.txt
while read line ;
do
j=$line
mkdir -p $j
curl -s -u admin:admin -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Restart HDFS Client","operation_level":{"level":"HOST_COMPONENT","cluster_name":"rest","host_name":"$j","service_name":"HDFS"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://ambari:8080/api/v1/clusters/rest/hosts/$j/host_components/HDFS_CLIENT
done < hostcluster.txt

 

View solution in original post

1 REPLY 1

avatar
Expert Contributor

I was able to figure out with the help of below community article.
https://community.cloudera.com/t5/Community-Articles/How-to-install-all-clients-on-all-nodes-in-your...

cluster/ta-p/246821

script.sh
---------
curl -s -u admin:admin http://ambari:8080/api/v1/hosts|grep host_name|sed -n 's/.*"host_name" : "\([^\"]*\)".*/\1/p'>hostcluster.txt
while read line ;
do
j=$line
mkdir -p $j
curl -s -u admin:admin -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Restart HDFS Client","operation_level":{"level":"HOST_COMPONENT","cluster_name":"rest","host_name":"$j","service_name":"HDFS"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://ambari:8080/api/v1/clusters/rest/hosts/$j/host_components/HDFS_CLIENT
done < hostcluster.txt