자주 쓰이는 Ambari REST API 정리
자주 쓰이는 Ambari Rest API에 대해 정리. Cloudera Manager도 비슷한 구조로 REST API를 사용할 수 있는데 사용해 보지 않아 정확히 모름.
관련 Apache WIKI
Service 상태 점검
#
curl -u admin:admin -X GET http://[SERVER_HOSTNAME]:8080/api/v1/clusters/
[CLUSTER_NAME]
/services/[SERVICE_NAME]
# curl -u admin:admin -X GET http://192.168.11.148:8080/api/v1/clusters/prum/services/HAWQ
Service 중지
# curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop Service
via REST
"},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://
[SERVER_HOSTNAME]
:8080/api/v1/clusters/[CLUSTER_NAME]/services/
[SERVICE_NAME]
curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop Service
via REST
"},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://192.168.11.148:8080/api/v1/clusters/prum/services/HAWQ
Service 시작
# curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Start
Service
via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'
http://
[SERVER_HOSTNAME]
:8080/api/v1/clusters/[CLUSTER_NAME]/services/
[SERVICE_NAME]
# curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Start
Service
via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}' http://hdm1.gphd.local:8080/api/v1/clusters/prum/services/HDFS
Configuration 수정
- 주의점 : delete 시 Ambari UI 상에서 완전 삭제 됨, set을 이용하여 다시 추가 가능
- set을 이용하여 추가 시 Advanced에 추가되는 것이 아닌 Custom으로 추가 됨, 원래 위치가 Advanced 여도 마찬가지
# /var/lib/ambari-server/resources/scripts/configs.sh [set|get|delete] [hostname] [clustername] [config_file_name] [config_key] [config_value]
# /var/lib/ambari-server/resources/scripts/configs.sh set localhost prum mapred-site "mapreduce.map.memory.mb" "512"
#
/var/lib/ambari-server/resources/scripts/configs.sh get
localhost prum mapred-site
# /var/lib/ambari-server/resources/scripts/configs.sh delete localhost prum mapred-site "mapreduce.map.memory.mb"
서비스 제거
# curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://
[SERVER_HOSTNAME]:8080/api/v1/clusters/
[CLUSTER_NAME]
/services/
[SERVICE_NAME]
# curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://192.168.11.151:8080/api/v1/clusters/prum/services/NAGIOS
특정 컴포넌트 제거
# curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE
http://
[SERVER_HOSTNAME]:8080/api/v1/clusters/
[CLUSTER_NAME]
/services/
[SERVICE_NAME]/[COMPONENT_NAME]
# curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE http://localhost.localdomain:8080/api/v1/clusters/prum/hosts/localhost.localdomain/host_components/HAWQSTANDBY
특정 컴포넌트 다시 추가
curl -u admin:admin -H "X-Requested-By: ambari" -i -X POST http://192.168.11.151:8080/api/v1/clusters/prum/services/HAWQ/components/HAWQSTANDBY
댓글
댓글 쓰기