Created 01-15-2019 11:19 AM
we have ambari cluster with 176 datanodes machines ( workers )
each datanode have the following component:
DataNode / HDFS Metrics Monitor / Ambari Metrics NodeManager / YARN
how to restart all these component on all datanode machines by API
* because it will take time to restart all datanode component manual as ( access each datanode machine from ambari and perform --> host actions --> restart all )
Created 01-15-2019 11:51 AM
Step1). You can get all the Hostnames where the DataNode is present using the following API call:
# curl --user admin:admin -H 'X-Requested-By: ambari' -X GET "http://newhwx1.example.com:8080/api/v1/clusters/NewCluster/services/HDFS/components/DATANODE?fields=host_components/HostRoles/host_name" | grep host_name | awk '{print $NF}' | awk -F'"' '{print $2}'
.
Step2). Once you have the list of the hosts where the Datanode is installed (using above API call) then you can use it to make the following API call using some shell script to replace the $HOST with the hostname.
# curl --user admin:admin -H 'X-Requested-By: ambari' -X POST -d '{"RequestInfo":{"command":"RESTART","context":"Restart all components on $HOST","operation_level":{"level":"HOST","cluster_name":"NewCluster"}},"Requests/resource_filters":[{"service_name":"HDFS","component_name":"DATANODE","hosts":"$HOST"}, {"service_name":"YARN","component_name":"NODEMANAGER","hosts":"$HOST"}, {"service_name":"AMBARI_METRICS","component_name":"METRICS_MONITOR","hosts":"$HOST"} ]}' http://ambariserver.example.com:8080/api/v1/clusters/NewCluster/requests
.
NOTE: In the above call please make sure to replace the $HOST with the hostname one by one (using some shell script Loop iteration) which we retrieved from the previous API call.
Also please replace the "NewCluster" with your own cluster name.
Also please replace "ambariserver.example.com" with your ambari hostname and credentials accordingly.
Created 01-15-2019 11:51 AM
Step1). You can get all the Hostnames where the DataNode is present using the following API call:
# curl --user admin:admin -H 'X-Requested-By: ambari' -X GET "http://newhwx1.example.com:8080/api/v1/clusters/NewCluster/services/HDFS/components/DATANODE?fields=host_components/HostRoles/host_name" | grep host_name | awk '{print $NF}' | awk -F'"' '{print $2}'
.
Step2). Once you have the list of the hosts where the Datanode is installed (using above API call) then you can use it to make the following API call using some shell script to replace the $HOST with the hostname.
# curl --user admin:admin -H 'X-Requested-By: ambari' -X POST -d '{"RequestInfo":{"command":"RESTART","context":"Restart all components on $HOST","operation_level":{"level":"HOST","cluster_name":"NewCluster"}},"Requests/resource_filters":[{"service_name":"HDFS","component_name":"DATANODE","hosts":"$HOST"}, {"service_name":"YARN","component_name":"NODEMANAGER","hosts":"$HOST"}, {"service_name":"AMBARI_METRICS","component_name":"METRICS_MONITOR","hosts":"$HOST"} ]}' http://ambariserver.example.com:8080/api/v1/clusters/NewCluster/requests
.
NOTE: In the above call please make sure to replace the $HOST with the hostname one by one (using some shell script Loop iteration) which we retrieved from the previous API call.
Also please replace the "NewCluster" with your own cluster name.
Also please replace "ambariserver.example.com" with your ambari hostname and credentials accordingly.