Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

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
New Member

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.