使用 CDH(CM) API 通过命令行管理CDH服务 zookeeper kafka

目录

1.获取集群名称

2.获取集群中所有服务

3.获取zookeeper 和kafka 服务状态

4.关闭/启动/重启集群的所有服务

5.关闭/启动/重启集群中的单个服务(zookeeper,kafka)

6.集群中kafka/zookeeper配置信息查看

7.显示kafka完整配置信息(包括默认配置)

8.修改kafka配置信息

参考:


1.获取集群名称

curl -X get -u admin:admin 'http://localhost:7180/api/v1/clusters'

注: admin:admin     为 CM用户名和密码

2.获取集群中所有服务

curl -X get -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services'

注:Cluster%201  为第1步获取的集群名称,由于Cluster 1 中有个空格,所以需要转义为 %20

3.获取zookeeper 和kafka 服务状态

curl -X get -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/zookeeper'
curl -X get -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/kafka'

注:其中 zookeeper 和 kafka 分别为第2步获取的服务名称

4.关闭/启动/重启集群的所有服务

curl -X post -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/commands/stop'
curl -X post -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/commands/start'
curl -X post -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/commands/restart'

注: 命令操作是post 方法,

5.关闭/启动/重启集群中的单个服务(zookeeper,kafka)

curl -X post -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/zookeeper/commands/stop'
curl -X post -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/zookeeper/commands/start'
curl -X post -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/zookeeper/commands/restart'
curl -X post -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/kafka/commands/stop'
curl -X post -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/kafka/commands/start'
curl -X post -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/kafka/commands/restart'

6.集群中kafka/zookeeper配置信息查看

curl -X get -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/kafka/config'
curl -X get -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/zookeeper/config'

注:这里只显示用户自定义的配置,如果是默认的配置则不显示。

7.显示kafka完整配置信息(包括默认配置)

curl -X get -u admin:admin 'http://localhost:7180/api/v1/clusters/Cluster%201/services/kafka/config?view=full'

8.修改kafka配置信息

curl -X PUT -H "Content-Type:application/json" -u admin:admin   -d '{ "items": [ { "name": "default.replication.factor", "value": "4" }] }'   'http://localhost:7180/api/v1/clusters/Cluster%201/services/kafka/config'

 

参考:

https://www.lmlphp.com/user/16587/article/item/465119

http://cloudera.github.io/cm_api/apidocs/v1/index.html

http://cloudera.github.io/cm_api/apidocs/v1/tutorial.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值