Saturday, February 3, 2018

Use Python script to manage Cloudera CDH services



# pip install cm-api
#API Doc: https://cloudera.github.io/cm_api/docs/python-client/

[donghua@cdh-vm scripts]$ ./start_cluster.py 
: cluster; version: CDH5

Name: hdfs             Before: STOPPED       Result: True
Name: zookeeper        Before: STOPPED       Result: True
Name: yarn             Before: STOPPED       Result: True
Name: spark_on_yarn    Before: STOPPED       Result: True
Name: hive             Before: STOPPED       Result: True
Name: impala           Before: STOPPED       Result: True
Name: hue              Before: STOPPED       Result: True

[donghua@cdh-vm scripts]$ ./status_cluster.py 
: cluster; version: CDH5

Service Name   Service State Health Summary
--------------- ------------- --------------
hdfs           STARTED       GOOD
yarn           STARTED       GOOD
spark_on_yarn   STARTED       GOOD
hive           STARTED       GOOD
zookeeper       STARTED       GOOD
impala         STARTED       GOOD
oozie           STOPPED       DISABLED
hue             STARTED       GOOD
sqoop_client   NA           GOOD