Kafka Active Controller

What is a Controller?

The controller is one of the Kafka brokers, usually behaves like a normal broker, and has a controlling capability of managing partition state and replicas and reassignment of the partition.

How to get the currently active controller?

Zookeeper is the storage of the Kafka cluster, who elects the controller node either at the beginning of the cluster setup or when the controller node crashes. Here is the command to get the controller

  • Shell command when installed on the host
zookeeper-shell 192.168.1.1:22181 get /controller
  • When we are dealing with the docker container we can execute the above command in interactive mode as follows
# Connect to Zookeeper
docker run --net=host --rm confluentinc/cp-kafka:4.0.0 zookeeper-shell 192.168.1.1:22181
# Get the Controller
docker run --net=host --rm confluentinc/cp-kafka:4.0.0 zookeeper-shell 192.168.1.1:22181 get /controller

Note: 192.168.1.1 is the zookeeper IP

--

--