Support Questions

Find answers, ask questions, and share your expertise

AMBARI REST API + how to stop/start individual kafka broker in kafka cluster

avatar

hi all

 

 

we have 5 kafka brokers 

 

we can stop or start the kafka service by API 

but how to stop specific kafka broker by REST API?

 

for example , in this pic we can see 5 kafka brokers , and we want to stop/start only the second kafka broker by REST API

 

Capture.PNG

 

Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Master Mentor

@mike_bronson7 

1. You can get the List of KAFKA Broker Hosts (hostnames) using the following API call.

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X GET http://$AMBARI_HOST:8080/api/v1/clusters/TestCluster/services/KAFKA/components/KAFKA_BROKER?fields=host_components/HostRoles/host_name


2. Once you know/decide the Hostname (For example: 'kafkabroker5.example.com') in which you want to stop/start the Kafka Broker then you can try the following:

.


A.  To Stop Kafka Broker on Host 'kafkabroker5.example.com'

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop Kafka Broker","operation_level":{"level":"HOST_COMPONENT","cluster_name":"TestCluster","host_name":"kafkabroker5.example.com","service_name":"KAFKA"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/TestCluster/hosts/kafkabroker5.example.com/host_components/KAFKA_BROKER

.


B.  To Start Kafka Broker on Host 'kafkabroker5.example.com'

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Start Kafka Broker","operation_level":{"level":"HOST_COMPONENT","cluster_name":"TestCluster","host_name":"kafkabroker5.example.com","service_name":"KAFKA"}},"Body":{"HostRoles":{"state":"STARTED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/TestCluster/hosts/kafkabroker5.example.com/host_components/KAFKA_BROKER

 

 

.

 

View solution in original post

1 REPLY 1

avatar
Master Mentor

@mike_bronson7 

1. You can get the List of KAFKA Broker Hosts (hostnames) using the following API call.

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X GET http://$AMBARI_HOST:8080/api/v1/clusters/TestCluster/services/KAFKA/components/KAFKA_BROKER?fields=host_components/HostRoles/host_name


2. Once you know/decide the Hostname (For example: 'kafkabroker5.example.com') in which you want to stop/start the Kafka Broker then you can try the following:

.


A.  To Stop Kafka Broker on Host 'kafkabroker5.example.com'

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop Kafka Broker","operation_level":{"level":"HOST_COMPONENT","cluster_name":"TestCluster","host_name":"kafkabroker5.example.com","service_name":"KAFKA"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/TestCluster/hosts/kafkabroker5.example.com/host_components/KAFKA_BROKER

.


B.  To Start Kafka Broker on Host 'kafkabroker5.example.com'

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Start Kafka Broker","operation_level":{"level":"HOST_COMPONENT","cluster_name":"TestCluster","host_name":"kafkabroker5.example.com","service_name":"KAFKA"}},"Body":{"HostRoles":{"state":"STARTED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/TestCluster/hosts/kafkabroker5.example.com/host_components/KAFKA_BROKER

 

 

.