ambari-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yusaku Sako <yus...@hortonworks.com>
Subject Re: Start/stop all services programmatically
Date Thu, 09 Apr 2015 00:33:46 GMT
Sorry, forgot to answer your second question regarding dependencies.
Such dependencies are specified in a file called role_command_order.json as part of the stack
defintion.

https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.0.6/role_command_order.json

If you try to start/stop all services in bulk, the command order rules will be followed automatically
by the server.

Yusaku

From: Yusaku Sako <yusaku@hortonworks.com<mailto:yusaku@hortonworks.com>>
Reply-To: "user@ambari.apache.org<mailto:user@ambari.apache.org>" <user@ambari.apache.org<mailto:user@ambari.apache.org>>
Date: Wednesday, April 8, 2015 5:27 PM
To: "user@ambari.apache.org<mailto:user@ambari.apache.org>" <user@ambari.apache.org<mailto:user@ambari.apache.org>>
Subject: Re: Start/stop all services programmatically

Hi Krzysztof,

You can do everything that the UI does with the API.
The best way to learn what API calls the UI is making is to use the browser's developer tool
and watch the network traffic.

Stop all services:
curl -i -uadmin:admin -H "X-Requested-By: ambari" -X PUT -d '
{"RequestInfo":{"context":"Stop all services","operation_level":{"level":"CLUSTER","cluster_name":"ing_hdp"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}
' http://ambari:8080/api/v1/clusters/ing_hdp/services

Start all services:
curl -i -uadmin:admin -H "X-Requested-By: ambari" -X PUT -d '
{"RequestInfo":{"context":"Start all services","operation_level":{"level":"CLUSTER","cluster_name":"ing_hdp"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}
' http://ambari:8080/api/v1/clusters/ing_hdp/services

I hope this helps.
Yusaku

From: Krzysztof Adamski <adamskikrzysiek@gmail.com<mailto:adamskikrzysiek@gmail.com>>
Reply-To: "user@ambari.apache.org<mailto:user@ambari.apache.org>" <user@ambari.apache.org<mailto:user@ambari.apache.org>>
Date: Tuesday, April 7, 2015 12:15 AM
To: "user@ambari.apache.org<mailto:user@ambari.apache.org>" <user@ambari.apache.org<mailto:user@ambari.apache.org>>
Subject: Start/stop all services programmatically

Hello,

I am busy implementing a manual job to stop all hosts services via script before rebooting
the OS. The examples I found in wiki are per service or component.

1. Is there any way to invoke the stop/start for all hosts components just like from a web
interface?
2. How ambari determines the proper order for the services to start/stop e.g. first stop hiveserver
before stopping mysql etc.

curl -s --user admin:admin -H "X-Requested-By: ambari" -X GET "http://ambari:8080/api/v1/clusters/ing_hdp/components/?ServiceComponentInfo/category.in(SLAVE,MASTER)&host_components/HostRoles/host_name=host1&fields=host_components/HostRoles/component_name,host_components/HostRoles/state"
| jq -r '[[.items[].host_components[].HostRoles.component_name]]|tostring' | sed -r 's/[\["]//g'
| sed -r 's/[]]//g'
  function stop(){
curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Stop
'"$1"' via REST"}, "Body": {"HostRoles": {"state": "INSTALLED"}}}' http://ambari:8080/api/v1/clusters/ing_hdp/hosts/host1/host_components/$1
}
Thanks for any guide.

Mime
View raw message