Skip to main content
mike_bronson7
Gold ⭐️⭐️⭐️
Apr 7, 2019 2:37 AM UTC
Solved

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 ?

jsensharma
Platinum ⭐️⭐️
Apr 7, 2019 2:54 AM UTC

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

.

4 replies

jsensharma
Platinum ⭐️⭐️
Platinum ⭐️⭐️
Apr 7, 2019 2:54 AM UTC

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

.

Translate
mike_bronson7
Gold ⭐️⭐️⭐️
Apr 7, 2019 3:06 AM UTC

@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

Translate
Michael-Bronson
jsensharma
Platinum ⭐️⭐️
Platinum ⭐️⭐️
Apr 7, 2019 3:10 AM UTC
meenakrajani
Silver ⭐️⭐️
May 14, 2019 4:46 AM UTC

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.

Translate