Support Questions

Find answers, ask questions, and share your expertise

How can I put Secondary Namenode to maintenance mode using ambari REST API

avatar
Explorer

I want to turn on and off maintenance mode for Secondary NN using Ambari REST API. How can I do that?

1 ACCEPTED SOLUTION

avatar
Super Guru

@Shravan Kumar,

You can use the below API for Turn ON and Turn OFF respectively

curl -k -u <username>:<password> -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for SNameNode"},"Body":{"HostRoles":{"maintenance_state":"ON"}}}' http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/hosts/{hostname}/host_components/SE... 
curl -k -u <username>:<password> -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn Off Maintenance Mode for SNameNode"},"Body":{"HostRoles":{"maintenance_state":"OFF"}}}' http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/hosts/{hostname}/host_components/SE...

Replace the ambari-host,ambari-port , clustername and hostname placeholders with the original value.

Thanks,

Aditya

View solution in original post

1 REPLY 1

avatar
Super Guru

@Shravan Kumar,

You can use the below API for Turn ON and Turn OFF respectively

curl -k -u <username>:<password> -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for SNameNode"},"Body":{"HostRoles":{"maintenance_state":"ON"}}}' http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/hosts/{hostname}/host_components/SE... 
curl -k -u <username>:<password> -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo":{"context":"Turn Off Maintenance Mode for SNameNode"},"Body":{"HostRoles":{"maintenance_state":"OFF"}}}' http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/hosts/{hostname}/host_components/SE...

Replace the ambari-host,ambari-port , clustername and hostname placeholders with the original value.

Thanks,

Aditya