【ambari】ambari api使用

本文介绍了如何使用Ambari API,重点在于Ambari在大数据环境中的应用,帮助管理和监控Hadoop集群。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值