Support Questions
Find answers, ask questions, and share your expertise

What is the best process to shut down the test cluster during weekend and start it up weekdays?

Expert Contributor

We are running our cluster on ec2 instances.I would like to know the best process for shutting down the cluster during weekend and start it in week days through script. Can anyone please suggest the best way to do this? Thank you in advance.



stop all services, wait, stop all agents, wait, stop ambari server, wait, shutdown all machines @Ram D

Expert Contributor

How can i bring it up during week days?


@Ram D in reverse order :).

Expert Contributor

Smart answer 🙂 Liked it. @Artem Ervits

Expert Contributor

First, create your instances with EBS-backed storage to ensure you do not lose any data. There is a literal cost to using EBS but the savings you realize from not running 24x7 will more than offset the EBS cost.

Next, use the EC2 API to issue the startup and shutdown commands. You can use a scheduler (cron, etc.) to execute the commands on whatever schedule you like. You should also enable the automatic startup of the Ambari server and agents at boot time.

Lastly, create another scheduler script to issue the commands to start the services in the cluster after waiting a few minutes after the servers start up. The commands in will get you going.

Expert Contributor

Just to know, we can also use REST APIs to start the services right?



Expert Contributor

An advanced user? Super! Here is the skeleton command for REST startup:

curl -u $ADMIN_USER:$ADMIN_PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Start via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}' http:// server host>:8080/api/v1/clusters/<cluster id>/services/<service name> 

And here are the service names for typical set of services and the start order


The REST stop command takes the state back to INSTALLED and you reverse the start order:

curl -u $ADMIN_USER:$ADMIN_PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Start via REST"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}' http:// server host>:8080/api/v1/clusters/<cluster id>/services/<service name> 

The EC2 commands can look like this for a start:

/usr/local/bin/aws ec2 start-instances --instance-ids $instance

Assuming you have the AWS toolkit installed locally. Loop through a set of Instance IDs to execute.

And a stop command has this syntax:

/usr/local/bin/aws ec2 stop-instances --instance-ids $instance

Expert Contributor

@Terry Padgett If we stop the Namenode ec2 instances, will lost the RAM on that instance(metadata). How can we get it know, about all the datanodes and nodemanagers?