Support Questions

Find answers, ask questions, and share your expertise

Can anyone tell me REST API to put the host component in maintenance mode through REST API?

Expert Contributor

I tried this one..

curl -u admin:OpsAm-iAp1Pass -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn on Maintenance mode"}, "Body":{"ServiceInfo":{"maintenance state":"ON"}}}' http://viceroy10:8080/api/v1/clusters/et_cluster/hosts/serf120int.etops.tllsc.net/host_components/DA...

Result :

HTTP/1.1 200 OK User: admin Set-Cookie: AMBARISESSIONID=1acil15v0h4ve2hk9a1ac5gux;Path=/;HttpOnly Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: text/plain Content-Length: 0 Server: Jetty(8.1.17.v20150415)

I checked in ambari dashboard, nothing happend..

1 ACCEPTED SOLUTION

Use the below command instead. Note that to check whether datanode was put into maintenance mode, you will need to go to the Hosts tab in Ambari, navigate to the host running datanode and look for the maintenance icon there (ie the icon won't show up under Ambari > HDFS > Datanode because its a 'slave' component)

2673-screen-shot-2016-03-07-at-21558-pm.png

curl -u admin:OpsAm-iAp1Pass -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode For DataNode"}, "Body":{"HostRoles":{"maintenance_state":"ON"}}}' http://viceroy10:8080/api/v1/clusters/et_cluster/hosts/serf120int.etops.tllsc.net/host_components/DA...

View solution in original post

3 REPLIES 3

Use the below command instead. Note that to check whether datanode was put into maintenance mode, you will need to go to the Hosts tab in Ambari, navigate to the host running datanode and look for the maintenance icon there (ie the icon won't show up under Ambari > HDFS > Datanode because its a 'slave' component)

2673-screen-shot-2016-03-07-at-21558-pm.png

curl -u admin:OpsAm-iAp1Pass -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode For DataNode"}, "Body":{"HostRoles":{"maintenance_state":"ON"}}}' http://viceroy10:8080/api/v1/clusters/et_cluster/hosts/serf120int.etops.tllsc.net/host_components/DA...

Expert Contributor

@Ali Bajwa I tried same for NODEMANAGER, i am getting http 200 code. Its not getting excuted. Here is my command. Can you please tell me is there anything wrong?

curl -u admin:OpsAm-iAp1Pass -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Stop NODEMANAGER"}, "Body":{"HostRoles":{"state":"INSTALLED"}}}' http://viceroy10:8080/api/v1/clusters/et_cluster/hosts/serf120int.etops.tllsc.net/host_components/NO...

Thank you in advance.

You are invoking the API to stop nodemanager (not put in maintenance mode).

To put it in maintenance mode, try below:

curl -u admin:OpsAm-iAp1Pass -H "X-Requested-By:ambari"-i -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode For NodeManaager"}, "Body":{"HostRoles":{"maintenance_state":"ON"}}}' http://viceroy10:8080/api/v1/clusters/et_cluster/hosts/serf120int.etops.tllsc.net/host_components/NODEMANAGER

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.