Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How to set ambari service to maintenance mode by API

avatar


as all know we can set any service from ambari GUI to maintenance mode

so

is it possible to set any ambari service to maintenance mode by API command ?

Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Master Mentor

@Michael Bronson
Example Putting a Service (Spark2) in Maintenance Mode using API call:

Turning ON maintenance Mode for Spark2 Service

# curl -sH "X-Requested-By: ambari" -u admin:admin -X PUT  -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for Spark2"},"Body":{"ServiceInfo":{"maintenance_state":"ON"}}}'  http://newhwx1.example.com:8080/api/v1/clusters/NewCluster/services/SPARK2




Turning OFF maintenance Mode for Spark2 Service

# curl -sH "X-Requested-By: ambari" -u admin:admin -X PUT  -d '{"RequestInfo":{"context":"Turn Off Maintenance Mode for Spark2"},"Body":{"ServiceInfo":{"maintenance_state":"OFF"}}}'  http://newhwx1.example.com:8080/api/v1/clusters/NewCluster/services/SPARK2


Please change the cluster name "NewCluster" and ambari hostname + credentials according to yoiur env.

.

View solution in original post

4 REPLIES 4

avatar
Master Mentor

@Michael Bronson
Example Putting a Service (Spark2) in Maintenance Mode using API call:

Turning ON maintenance Mode for Spark2 Service

# curl -sH "X-Requested-By: ambari" -u admin:admin -X PUT  -d '{"RequestInfo":{"context":"Turn On Maintenance Mode for Spark2"},"Body":{"ServiceInfo":{"maintenance_state":"ON"}}}'  http://newhwx1.example.com:8080/api/v1/clusters/NewCluster/services/SPARK2




Turning OFF maintenance Mode for Spark2 Service

# curl -sH "X-Requested-By: ambari" -u admin:admin -X PUT  -d '{"RequestInfo":{"context":"Turn Off Maintenance Mode for Spark2"},"Body":{"ServiceInfo":{"maintenance_state":"OFF"}}}'  http://newhwx1.example.com:8080/api/v1/clusters/NewCluster/services/SPARK2


Please change the cluster name "NewCluster" and ambari hostname + credentials according to yoiur env.

.

avatar

@Jay , when we rrun this API we seen that also spark history became with maintenance mode

is it possible to set maintenance mode only to the thrift server and not to spark history ?



107691-capture.png

Michael-Bronson

avatar
Master Mentor

avatar

Hi can you put datanode in maintenance through bash command or direct python command? I have ginormous and i want to quickly stop and start services. I am using hadoop-daemon.sh start to to start a datanode. I know maintenence mode is not from hadoop API that is built as part of Ambari.