<?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 Re: How can I stop the entire HDP stack via the CLI? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100917#M13664</link>
    <description>&lt;P&gt;You can use a script like this to perform the shutdown of a cluster. The script below will first determine the cluster's name and then use it in subsequent calls to the API.&lt;/P&gt;&lt;PRE&gt;USER=admin
PASSWORD=admin
AMBARI_HOST=localhost

#detect name of cluster
CLUSTER=$(curl -s -u $USER:$PASSWORD -i -H 'X-Requested-By: ambari' \
   &lt;A href="http://$AMBARI_HOST:8080/api/v1/clusters" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters&lt;/A&gt; | \
   sed -n 's/.*"cluster_name" : "\([^\"]*\)".*/\1/p')

#stop all services
curl -u $USER:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT \
   -d '{"RequestInfo":{"context":"_PARSE_.STOP.ALL_SERVICES","operation_level":{"level":"CLUSTER","cluster_name":"Sandbox"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' \
   &lt;A href="http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services&lt;/A&gt;

#start all services
curl -u $USER:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT \
   -d '{"RequestInfo":{"context":"_PARSE_.START.ALL_SERVICES","operation_level":{"level":"CLUSTER","cluster_name":"Sandbox"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}' \
   &lt;A href="http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/service" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/service&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;When you run the above you'll see a response from the API like so (NOTE: here my cluster is called "dev09_ost_hivetest_h"):&lt;/P&gt;&lt;PRE&gt;HTTP/1.1 202 Accepted
User: admin
Set-Cookie: AMBARISESSIONID=1t9w52ud2xali10ofo3r9uw2t4;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 150
Server: Jetty(8.1.17.v20150415)

{
  "href" : "http://localhost:8080/api/v1/clusters/dev09_ost_hivetest_h/requests/42",
  "Requests" : {
    "id" : 42,
    "status" : "Accepted"
  }
&lt;/PRE&gt;&lt;P&gt;You can take the request ID ("id": 42) and monitor it to see if it's completed.&lt;/P&gt;&lt;PRE&gt;$ curl -s -u admin:admin -i -H 'X-Requested-By: ambari' &lt;A href="http://localhost:8080/api/v1/clusters/dev09_ost_hivetest_h/requests/42" target="_blank"&gt;http://localhost:8080/api/v1/clusters/dev09_ost_hivetest_h/requests/42&lt;/A&gt;

HTTP/1.1 200 OK
User: admin
Set-Cookie: AMBARISESSIONID=ypsi94kpge383tn0n1aosf9p;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 5593
Server: Jetty(8.1.17.v20150415)

{
  "href" : "http://localhost:8080/api/v1/clusters/dev09_ost_hivetest_h/requests/42",
  "Requests" : {
    "aborted_task_count" : 0,
    "cluster_name" : "dev09_ost_hivetest_h",
    "completed_task_count" : 16,
    "create_time" : 1455901657726,
    "end_time" : 1455901773056,
    "exclusive" : false,
    "failed_task_count" : 0,
    "id" : 42,
    "inputs" : null,
    "operation_level" : null,
    "progress_percent" : 100.0,
    "queued_task_count" : 0,
    "request_context" : "_PARSE_.STOP.ALL_SERVICES",
    "request_schedule" : null,
    "request_status" : "COMPLETED",
    "resource_filters" : [ ],
    "start_time" : 1455901657749,
    "task_count" : 16,
    "timed_out_task_count" : 0,
    "type" : "INTERNAL_REQUEST"
  },
...
...&lt;/PRE&gt;&lt;P&gt;When it says COMPLETED, the shutdown is done.&lt;/P&gt;</description>
    <pubDate>Sat, 20 Feb 2016 01:16:38 GMT</pubDate>
    <dc:creator>slm</dc:creator>
    <dc:date>2016-02-20T01:16:38Z</dc:date>
    <item>
      <title>How can I stop the entire HDP stack via the CLI?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100912#M13659</link>
      <description>&lt;P&gt;How can I stop the entire HDP stack of services from the CLI? I seem to recall that there was a command to accomplish this but I can not find it. It would seem like this facility would be associated with the ambari-agent service but I did not see any such method/action on the usage for this script/service.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 03:08:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100912#M13659</guid>
      <dc:creator>slm</dc:creator>
      <dc:date>2015-12-29T03:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stop the entire HDP stack via the CLI?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100913#M13660</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/1461/hortonworks.html" nodeid="1461"&gt;@Sam Mingolelli&lt;/A&gt; I am not sure if there was ever any single CLI command to stop entire HDP stack. But you can use Ambari APIs to start or stop all services. Refer below for the same.&lt;/P&gt;&lt;P&gt;&lt;A href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=41812517" target="_blank"&gt;https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=41812517&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 03:12:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100913#M13660</guid>
      <dc:creator>pardeep_kumar</dc:creator>
      <dc:date>2015-12-29T03:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stop the entire HDP stack via the CLI?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100914#M13661</link>
      <description>&lt;P&gt;curl -u &amp;lt;USERNAME&amp;gt;:&amp;lt;PASSWORD&amp;gt; -H 'X-Requested-By:ambari' -X PUT -d '{"RequestInfo":{"context":"Stop All Services","operation_level":{"level":"CLUSTER","cluster_name":"cl1"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' &lt;A href="http://&amp;lt;AMBARI-SERVER&amp;gt;:8080/api/v1/clusters/cl1/services" target="_blank"&gt;http://&amp;lt;AMBARI-SERVER&amp;gt;:8080/api/v1/clusters/cl1/services&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 03:20:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100914#M13661</guid>
      <dc:creator>jluniya</dc:creator>
      <dc:date>2015-12-29T03:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stop the entire HDP stack via the CLI?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100915#M13662</link>
      <description>&lt;P&gt;See the following Question &lt;A href="https://community.hortonworks.com/questions/825/how-to-write-cluster-startup-shutdown-order-and-sc.html"&gt;How to Write Cluster Startup and Shutdown Scripts with Ambari&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 03:23:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100915#M13662</guid>
      <dc:creator>amcbarnett</dc:creator>
      <dc:date>2015-12-29T03:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stop the entire HDP stack via the CLI?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100916#M13663</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/1461/hortonworks.html" nodeid="1461"&gt;@Sam Mingolelli&lt;/A&gt; please accept the best answer or provide your own solution.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2016 04:16:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100916#M13663</guid>
      <dc:creator>aervits</dc:creator>
      <dc:date>2016-02-06T04:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stop the entire HDP stack via the CLI?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100917#M13664</link>
      <description>&lt;P&gt;You can use a script like this to perform the shutdown of a cluster. The script below will first determine the cluster's name and then use it in subsequent calls to the API.&lt;/P&gt;&lt;PRE&gt;USER=admin
PASSWORD=admin
AMBARI_HOST=localhost

#detect name of cluster
CLUSTER=$(curl -s -u $USER:$PASSWORD -i -H 'X-Requested-By: ambari' \
   &lt;A href="http://$AMBARI_HOST:8080/api/v1/clusters" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters&lt;/A&gt; | \
   sed -n 's/.*"cluster_name" : "\([^\"]*\)".*/\1/p')

#stop all services
curl -u $USER:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT \
   -d '{"RequestInfo":{"context":"_PARSE_.STOP.ALL_SERVICES","operation_level":{"level":"CLUSTER","cluster_name":"Sandbox"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' \
   &lt;A href="http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services&lt;/A&gt;

#start all services
curl -u $USER:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT \
   -d '{"RequestInfo":{"context":"_PARSE_.START.ALL_SERVICES","operation_level":{"level":"CLUSTER","cluster_name":"Sandbox"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}' \
   &lt;A href="http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/service" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/service&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;When you run the above you'll see a response from the API like so (NOTE: here my cluster is called "dev09_ost_hivetest_h"):&lt;/P&gt;&lt;PRE&gt;HTTP/1.1 202 Accepted
User: admin
Set-Cookie: AMBARISESSIONID=1t9w52ud2xali10ofo3r9uw2t4;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 150
Server: Jetty(8.1.17.v20150415)

{
  "href" : "http://localhost:8080/api/v1/clusters/dev09_ost_hivetest_h/requests/42",
  "Requests" : {
    "id" : 42,
    "status" : "Accepted"
  }
&lt;/PRE&gt;&lt;P&gt;You can take the request ID ("id": 42) and monitor it to see if it's completed.&lt;/P&gt;&lt;PRE&gt;$ curl -s -u admin:admin -i -H 'X-Requested-By: ambari' &lt;A href="http://localhost:8080/api/v1/clusters/dev09_ost_hivetest_h/requests/42" target="_blank"&gt;http://localhost:8080/api/v1/clusters/dev09_ost_hivetest_h/requests/42&lt;/A&gt;

HTTP/1.1 200 OK
User: admin
Set-Cookie: AMBARISESSIONID=ypsi94kpge383tn0n1aosf9p;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 5593
Server: Jetty(8.1.17.v20150415)

{
  "href" : "http://localhost:8080/api/v1/clusters/dev09_ost_hivetest_h/requests/42",
  "Requests" : {
    "aborted_task_count" : 0,
    "cluster_name" : "dev09_ost_hivetest_h",
    "completed_task_count" : 16,
    "create_time" : 1455901657726,
    "end_time" : 1455901773056,
    "exclusive" : false,
    "failed_task_count" : 0,
    "id" : 42,
    "inputs" : null,
    "operation_level" : null,
    "progress_percent" : 100.0,
    "queued_task_count" : 0,
    "request_context" : "_PARSE_.STOP.ALL_SERVICES",
    "request_schedule" : null,
    "request_status" : "COMPLETED",
    "resource_filters" : [ ],
    "start_time" : 1455901657749,
    "task_count" : 16,
    "timed_out_task_count" : 0,
    "type" : "INTERNAL_REQUEST"
  },
...
...&lt;/PRE&gt;&lt;P&gt;When it says COMPLETED, the shutdown is done.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2016 01:16:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100917#M13664</guid>
      <dc:creator>slm</dc:creator>
      <dc:date>2016-02-20T01:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I stop the entire HDP stack via the CLI?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100918#M13665</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/1461/hortonworks.html" nodeid="1461"&gt;@Sam Mingolelli&lt;/A&gt;  See this &lt;A href="https://gist.github.com/randerzander/5b7b0e075e59f87d3c84" target="_blank"&gt;https://gist.github.com/randerzander/5b7b0e075e59f87d3c84&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is much better approach ..Thanks to &lt;A rel="user" href="https://community.cloudera.com/users/157/rgelhausen.html" nodeid="157"&gt;@Randy Gelhausen&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2016 01:27:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-stop-the-entire-HDP-stack-via-the-CLI/m-p/100918#M13665</guid>
      <dc:creator>nsabharwal</dc:creator>
      <dc:date>2016-02-20T01:27:57Z</dc:date>
    </item>
  </channel>
</rss>

