<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question how to restart all datanode component by API in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/how-to-restart-all-datanode-component-by-API/m-p/242224#M204027</link>
    <description>&lt;P&gt;we have ambari cluster with &lt;STRONG&gt;&lt;EM&gt;176 datanodes&lt;/EM&gt;&lt;/STRONG&gt; machines ( workers )&lt;/P&gt;&lt;P&gt;each datanode have the following component:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/96719-capture.png"&gt;capture.png&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;DataNode  /  HDFS
Metrics Monitor  /  Ambari Metrics
NodeManager  /  YARN
&lt;/PRE&gt;&lt;P&gt;how to restart all these component on all datanode machines by API&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;* because it will take time to restart all datanode component manual as ( access each datanode machine from ambari and perform --&amp;gt; host actions --&amp;gt; restart all )&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Jan 2019 19:19:27 GMT</pubDate>
    <dc:creator>mike_bronson7</dc:creator>
    <dc:date>2019-01-15T19:19:27Z</dc:date>
    <item>
      <title>how to restart all datanode component by API</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-restart-all-datanode-component-by-API/m-p/242224#M204027</link>
      <description>&lt;P&gt;we have ambari cluster with &lt;STRONG&gt;&lt;EM&gt;176 datanodes&lt;/EM&gt;&lt;/STRONG&gt; machines ( workers )&lt;/P&gt;&lt;P&gt;each datanode have the following component:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/96719-capture.png"&gt;capture.png&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;DataNode  /  HDFS
Metrics Monitor  /  Ambari Metrics
NodeManager  /  YARN
&lt;/PRE&gt;&lt;P&gt;how to restart all these component on all datanode machines by API&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;* because it will take time to restart all datanode component manual as ( access each datanode machine from ambari and perform --&amp;gt; host actions --&amp;gt; restart all )&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2019 19:19:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-restart-all-datanode-component-by-API/m-p/242224#M204027</guid>
      <dc:creator>mike_bronson7</dc:creator>
      <dc:date>2019-01-15T19:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to restart all datanode component by API</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-restart-all-datanode-component-by-API/m-p/242225#M204028</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/26229/uribarih.html" nodeid="26229"&gt;@Michael Bronson&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step1). &lt;/STRONG&gt; You can get all the Hostnames where the DataNode is present using the following API call:&lt;/P&gt;&lt;PRE&gt;# 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}'
&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step2).&lt;/STRONG&gt; 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.&lt;/P&gt;&lt;PRE&gt;# 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"} ]}' &lt;A href="http://ambariserver.example.com:8080/api/v1/clusters/NewCluster/requests" target="_blank"&gt;http://ambariserver.example.com:8080/api/v1/clusters/NewCluster/requests&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:  &lt;/STRONG&gt;In the above call please make sure to replace the &lt;STRONG&gt;$HOST with the hostname one by one (using some shell script Loop iteration)&lt;/STRONG&gt; which we retrieved from the previous API call.&lt;BR /&gt;Also please replace the "NewCluster" with your own cluster name.&lt;/P&gt;&lt;P&gt;Also please replace "ambariserver.example.com" with your ambari hostname and credentials accordingly.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jan 2019 19:51:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-restart-all-datanode-component-by-API/m-p/242225#M204028</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2019-01-15T19:51:17Z</dc:date>
    </item>
  </channel>
</rss>

