Created on 02-27-2020 01:39 PM - last edited on 02-27-2020 03:55 PM by lwang
hi all
in ambari we have kafka service , and this service include 7 kafka brokers
how to stop/start the kafka broker on specific host?
in this example kafka service contain the following kafka broker hosts
kafka01
kafka02
kafka03
kafka04
kafka05
kafka06
kafka07
other repleted post - https://community.cloudera.com/t5/Support-Questions/how-to-identify-alert-from-kafka-service-in-amba...
Created on 02-27-2020 03:41 PM - edited 02-27-2020 03:43 PM
Using API call Get the List of Hostnames where KAFKA_BROKERS are running:
Example:
# curl -iskH "X-Requested-By: ambari" -X GET -u admin:admin ttp://testnode1.example.com:8080/api/v1/clusters/NewCluster/services/KAFKA/components/KAFKA_BROKER?fields=host_components/HostRoles/hostname | grep host_name | awk -F ":" '{print $2}' | sed -e 's|["'\'']||g'
testnode2.example.com
testnode3.example.com
testnode5.example.com
The API call to Start Kafka Broker on Node "testnode2.example.com" can be achieved as following:
# curl -iskH "X-Requested-By: ambari" -u admin:admin -X PUT -d '{"RequestInfo":{"context":"Start Kafka Broker","operation_level":{"level":"HOST_COMPONENT","cluster_name":"NewCluster","host_name":"testnode2.example.com","service_name":"KAFKA"}},"Body":{"HostRoles":{"state":"STARTED"}}}' ttp://testnode1.example.com:8080/api/v1/clusters/NewCluster/hosts/testnode2.example.com/host_components/KAFKA_BROKER
The API call to Stop Kafka Broker on Node "testnode2.example.com" can be achieved as following:
# curl -iskH "X-Requested-By: ambari" -u admin:admin -X PUT -d '{"RequestInfo":{"context":"Stop Kafka Broker","operation_level":{"level":"HOST_COMPONENT","cluster_name":"NewCluster","host_name":"testnode2.example.com","service_name":"KAFKA"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' ttp://testnode1.example.com:8080/api/v1/clusters/NewCluster/hosts/testnode2.example.com/host_components/KAFKA_BROKER
.
.
Created 02-27-2020 04:34 PM
Error says :
hostname=kafka01. Host not found
So please check if the Hostname is correct (i means fully qualified hostnmae)
Please compare it with the hostname listed in the following API call response. Just try to open this URL in the browser to see which hostname ambari is expecting:
http://ambari_server_hostname:8080/api/v1/clusters/$CLUSTER_NAME/hosts/
.
Created on 02-27-2020 03:41 PM - edited 02-27-2020 03:43 PM
Using API call Get the List of Hostnames where KAFKA_BROKERS are running:
Example:
# curl -iskH "X-Requested-By: ambari" -X GET -u admin:admin ttp://testnode1.example.com:8080/api/v1/clusters/NewCluster/services/KAFKA/components/KAFKA_BROKER?fields=host_components/HostRoles/hostname | grep host_name | awk -F ":" '{print $2}' | sed -e 's|["'\'']||g'
testnode2.example.com
testnode3.example.com
testnode5.example.com
The API call to Start Kafka Broker on Node "testnode2.example.com" can be achieved as following:
# curl -iskH "X-Requested-By: ambari" -u admin:admin -X PUT -d '{"RequestInfo":{"context":"Start Kafka Broker","operation_level":{"level":"HOST_COMPONENT","cluster_name":"NewCluster","host_name":"testnode2.example.com","service_name":"KAFKA"}},"Body":{"HostRoles":{"state":"STARTED"}}}' ttp://testnode1.example.com:8080/api/v1/clusters/NewCluster/hosts/testnode2.example.com/host_components/KAFKA_BROKER
The API call to Stop Kafka Broker on Node "testnode2.example.com" can be achieved as following:
# curl -iskH "X-Requested-By: ambari" -u admin:admin -X PUT -d '{"RequestInfo":{"context":"Stop Kafka Broker","operation_level":{"level":"HOST_COMPONENT","cluster_name":"NewCluster","host_name":"testnode2.example.com","service_name":"KAFKA"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' ttp://testnode1.example.com:8080/api/v1/clusters/NewCluster/hosts/testnode2.example.com/host_components/KAFKA_BROKER
.
.
Created 02-27-2020 04:11 PM
Dear Jay +1 for your excellent answer
I will test this API soon when I will come to office , I will update soon
Created on 02-27-2020 04:25 PM - edited 02-27-2020 04:27 PM
Dear Jay
when we run the API we get the following
master02 - is the machine with ambari server
kafka01 - is the first kafka machine
where we are wrong ?
curl -iskH "X-Requested-By: ambari" -u admin:admin -X PUT -d '{"RequestInfo":{"context":"Stop Kafka Broker","operation_level":{"level":"HOST_COMPONENT","cluster_name":"NwCluster","host_name":"kafka01","service_name":"KAFKA"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://master02:8080/api/v1/clusters/HDP_SYS76/hosts/kafka01/host_components/KAFKA_BROKER
HTTP/1.1 404 Not Found
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=15lniq8gcyggwudtsp5sd70fp;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
User: admin
Content-Type: text/plain
Content-Length: 243
{
"status" : 404,
"message" : "org.apache.ambari.server.controller.spi.NoSuchParentResourceException: Parent Host resource doesn't exist. Host not found, cluster=HDP_SYS76, hostname=kafka01. Host not found, cluster=HDP_SYS76, hostname=kafka01"
Created 02-27-2020 04:34 PM
Error says :
hostname=kafka01. Host not found
So please check if the Hostname is correct (i means fully qualified hostnmae)
Please compare it with the hostname listed in the following API call response. Just try to open this URL in the browser to see which hostname ambari is expecting:
http://ambari_server_hostname:8080/api/v1/clusters/$CLUSTER_NAME/hosts/
.