Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

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