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 to set ambari service to maintenance mode by API


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

Super 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

Super 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.

.

@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

Super Mentor

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.