AmbariAPI使用
官网:https://cwiki.apache.org/confluence/display/AMBARI/Ambari
# 以clickhouse为例
1. 添加服务:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X POST -d '{"ServiceInfo":{"service_name":"{service_name}"}}' http://localhost:8080/api/v1/clusters/{cluster_name}/services/{service_name}
2. 添加组件:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X POST http://localhost:8080/api/v1/clusters/{cluster_name}/services/{service_name}/components/{component_name}
3. 创建配置:python ../scripts/configs.py -t 8080 -s http -a set -l localhost -n {cluster_name} -c clickhouse-server-zookeeper-xml -u {user} -p {password} -f ../clickhouse-server-zookeeper-xml.xml
【替代为接口
3.1 创建配置:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X POST -d '{"type":" <type_name>", "tag": "<tag_name>","properties": <properties>}' http://localhost:8080/api/v1/clusters/{cluster_name}/configurations
3.2 应用配置:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X PUT-d '{ "Clusters" : {"desired_configs": {"type": "<type_name>", "tag" : "<tag_name>" }}}' http://localhost:8080/api/v1/clusters/{cluster_name}
4. 创建主机组件:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X POST http://localhost:8080/api/v1/clusters/{cluster_name}/hosts/{host_name}/host_components/{component_name}
5. 安装服务:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X PUT -d '{"ServiceInfo": {"state" : "INSTALLED"}}' http://localhost:8080/api/v1/clusters/{cluster_name}/services/{service_name}
6. 启动服务:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X PUT -d '{"ServiceInfo": {"state" : "STARTED"}}' http://localhost:8080/api/v1/clusters/{cluster_name}/services/{service_name}
7. 安装组件:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo": {"context" :"install {component_name} via REST"}, "HostRoles": {"state": "INSTALLED"}' http://localhost:8080/api/v1/clusters/{cluster_name}/hosts/{host_name}/host_components/{component_name}
8. 启动组件:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X PUT -d '{"HostRoles": {"state" : "STARTED"}}' http://localhost:8080/api/v1/clusters/{cluster_name}/hosts/{host_name}/host_components/{component_name}
9. 查看指定configuration:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X GET http://localhost:8080/api/v1/clusters/{cluster_name}/configurations
10. 查看集群正在使用的config:curl -s -u {user}:{password} -H "X-Requested-By: ambari" -X GET http://localhost:8080/api/v1/clusters/{cluster_name}?fields=Clusters/desired_configs