<?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 to write Cluster Startup Shutdown order and Scripts with Ambari in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94798#M8071</link>
    <description>&lt;P&gt;Might be easier to invoke the Ambari APIs to stop/start all services. To do this at startup invoke these from your /etc/rc.d/rc.local:&lt;/P&gt;&lt;PRE&gt;USER=admin
PASSWORD=admin
AMBARI_HOST=localhost

#detect name of cluster
output=`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;
CLUSTER=`echo $output | 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/services" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;Instead of starting all services, you can also start services individually. See below example that starts only Kafka, Hbase, Storm&lt;/P&gt;&lt;PRE&gt;USER=admin
PASSWORD=admin
AMBARI_HOST=localhost

#detect name of cluster
output=`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;
CLUSTER=`echo $output | sed -n 's/.*"cluster_name" : "\([^\"]*\)".*/\1/p'`

for SERVICE in KAFKA HBASE STORM
do
	echo "starting $SERVICE"
	curl -u $USER:$PASSWORD -i -H "X-Requested-By: ambari" -X PUT -d "{\"RequestInfo\": {\"context\" :\"Start $SERVICE via REST\"}, \"Body\": {\"ServiceInfo\": {\"state\": \"STARTED\"}}}" &lt;A href="http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE&lt;/A&gt;
done	
&lt;/PRE&gt;</description>
    <pubDate>Sat, 03 Oct 2015 06:43:47 GMT</pubDate>
    <dc:creator>abajwa</dc:creator>
    <dc:date>2015-10-03T06:43:47Z</dc:date>
    <item>
      <title>How to write Cluster Startup Shutdown order and Scripts with Ambari</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94796#M8069</link>
      <description>&lt;P&gt;I am  running HDP on a Virtualized environment and for business reasons needs to be able to shut down/restart the cluster if necessary.&lt;/P&gt;&lt;P&gt;Need to figure out  how to write a shutdown script.  Which order should the services be started or shut down?&lt;/P&gt;</description>
      <pubDate>Sat, 03 Oct 2015 06:26:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94796#M8069</guid>
      <dc:creator>amcbarnett</dc:creator>
      <dc:date>2015-10-03T06:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to write Cluster Startup Shutdown order and Scripts with Ambari</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94797#M8070</link>
      <description>&lt;P&gt;Here is a start.
&lt;/P&gt;&lt;P&gt;Assuming HDP 2.2.x an order of services to shutdown (except name node ) is found at: &lt;A href="http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.2.8/bk_HDP_Reference_Guide/content/stopping_hdp_services.html"&gt;http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.2.8/bk_HDP_Reference_Guide/content/stopping_hdp_services.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The order to startup: &lt;A href="http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.2.8/bk_HDP_Reference_Guide/content/starting_hdp_services.html"&gt;http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.2.8/bk_HDP_Reference_Guide/content/starting_hdp_services.html

&lt;/A&gt;For HDP 2.3 -&amp;gt; &lt;A href="http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.0/bk_HDP_Reference_Guide/content/ch_controlling_hdp_svcs_manually.html" target="_blank"&gt;http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.0/bk_HDP_Reference_Guide/content/ch_controlling_hdp_svcs_manually.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is a sample control script you can use to start stop services&lt;/STRONG&gt;:  &lt;A href="https://gist.github.com/randerzander/5b7b0e075e59f87d3c84"&gt;https://gist.github.com/randerzander/5b7b0e075e59f87d3c84&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also read the Ambari API docs as suggested below on the Ambari APIs:  &lt;A href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=41812517"&gt;https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=41812517

&lt;/A&gt;--------------------------&lt;/P&gt;&lt;P&gt;export $PASSWORD = *****&lt;/P&gt;&lt;P&gt;export $CLUSTER_NAME = {Your Cluster Name}&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start HDFS via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/HDFS&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start YARN via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/YARN&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start MAPREDUCE2 via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/MAPREDUCE2&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start HIVE via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/HIVE&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start TEZ via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/TEZ&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start HCATALOG via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/HCATALOG&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start WEBHCAT via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/WEBHCAT&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start ZOOKEEPER via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/ZOOKEEPER&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start NAGIOS via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/NAGIOS&lt;/P&gt;&lt;P&gt;curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo": {"context" :"Start GANGLIA via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'http://`hostname -f`:8080/api/v1/clusters/$CLUSTER_NAME/services/GANGLIA&lt;/P&gt;</description>
      <pubDate>Sat, 03 Oct 2015 06:29:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94797#M8070</guid>
      <dc:creator>amcbarnett</dc:creator>
      <dc:date>2015-10-03T06:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to write Cluster Startup Shutdown order and Scripts with Ambari</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94798#M8071</link>
      <description>&lt;P&gt;Might be easier to invoke the Ambari APIs to stop/start all services. To do this at startup invoke these from your /etc/rc.d/rc.local:&lt;/P&gt;&lt;PRE&gt;USER=admin
PASSWORD=admin
AMBARI_HOST=localhost

#detect name of cluster
output=`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;
CLUSTER=`echo $output | 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/services" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;Instead of starting all services, you can also start services individually. See below example that starts only Kafka, Hbase, Storm&lt;/P&gt;&lt;PRE&gt;USER=admin
PASSWORD=admin
AMBARI_HOST=localhost

#detect name of cluster
output=`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;
CLUSTER=`echo $output | sed -n 's/.*"cluster_name" : "\([^\"]*\)".*/\1/p'`

for SERVICE in KAFKA HBASE STORM
do
	echo "starting $SERVICE"
	curl -u $USER:$PASSWORD -i -H "X-Requested-By: ambari" -X PUT -d "{\"RequestInfo\": {\"context\" :\"Start $SERVICE via REST\"}, \"Body\": {\"ServiceInfo\": {\"state\": \"STARTED\"}}}" &lt;A href="http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE" target="_blank"&gt;http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE&lt;/A&gt;
done	
&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Oct 2015 06:43:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94798#M8071</guid>
      <dc:creator>abajwa</dc:creator>
      <dc:date>2015-10-03T06:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to write Cluster Startup Shutdown order and Scripts with Ambari</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94799#M8072</link>
      <description>&lt;P&gt;Would not recommend creating these scripts manually because it is specific to Amabri version and you would need to change this script every release as new services are added as start order may change. Ambari knows the right order (check the role_command_order.json files under /var/lib/ambari-server). I would recommend to just use Ambaris APIs to start all and stop all so you don't have to worry about it every release. &lt;A rel="user" href="https://community.cloudera.com/users/313/yusaku.html" nodeid="313"&gt;@yusaku@hortonworks.com&lt;/A&gt; what do you think?&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2015 06:32:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94799#M8072</guid>
      <dc:creator>abajwa</dc:creator>
      <dc:date>2015-11-08T06:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to write Cluster Startup Shutdown order and Scripts with Ambari</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94800#M8073</link>
      <description>&lt;P&gt;Be cautious. The assumption with all techniques using the Ambari REST API to auto start the cluster is the notion that the ambari-server process is running and also reachable via the network.  I have seen cases in AWS where the network connection is not yet available to the Ambari server host, resulting in the REST calls failing.  &lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2015 12:19:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-to-write-Cluster-Startup-Shutdown-order-and-Scripts-with/m-p/94800#M8073</guid>
      <dc:creator>TerryP</dc:creator>
      <dc:date>2015-11-08T12:19:51Z</dc:date>
    </item>
  </channel>
</rss>

