Support Questions
Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Innovation Accelerator group hub.

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

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

@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

@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