This article covers various topics and initial configuration details for Kafka and zookeeper.
All Supported Smarts releases
Find the server.properties file, which is located in the KAFKA_HOME/config location:
$ locate server.propertiesView the file server.properties
$ less /opt/kafka/config/server.propertieslisteners=SASL_PLAINTEXT://#.#.#.#:<PORT Like 9092>zookeeper.connect=#.#.#.#:<PORT Like 2181>Ports in use by kafka and zookeeper services can be identified within this file .There should be java processes listening at these ports.
Check the kafka port listed in the server.properties:
$ sudo netstat -anp | grep <PORT Like 9092>The below output shows that there is a java process listening indicating good results.
tcp6 0 0 :::<PORT Like 9092> :::* LISTEN <PID Like 52922>/javaCheck to see if zookeeper process is listening to port 2181
$ sudo netstat -anp | grep <PORT Like 2181>The below output shows that there is a java process listening indicating good results.
tcp6 0 0 #.#.#.#:<PORT Like 2181> :::* LISTEN <PID Like 52926>/javaBest practice on Linux OS is to systemctl to create services for Kafka and Zookeeper, and use these to start and stop the processes.
Check the Kafka service status:
$ sudo systemctl statuskafka.service
/var/log/messages:<Date & Time> <Host> systemd: Stopping kafka.service...
<Date & Time> <Host> zookeeper-server-start.sh: [<Date & Time>,586] INFO Processed session termination for sessionid: #SESSIONID#(org.apache.zookeeper.server.PrepRequestProcessor)
<Date & Time> <Host> zookeeper-server-start.sh: [<Date & Time>,589] INFO Closed socket connection for client /#.#.#.#:<PORT> which had sessionid #SESSIONID# (org.apache.zookeeper.server.NIOServerCnxn)
<Date & Time> <Host> zookeeper-server-start.sh: [<Date & Time>,179] INFO Processed session termination for sessionid: #SESSIONID# (org.apache.zookeeper.server.PrepRequestProcessor)
<Date & Time> <Host> zookeeper-server-start.sh: [<Date & Time>,181] INFO Closed socket connection for client /#.#.#.#:<PORT> which had sessionid #SESSIONID# (org.apache.zookeeper.server.NIOServerCnxn)
<Date & Time> <Host> systemd: Started kafka.service.$ export KAFKA_OPTS=-Djava.security.auth.login.config=/opt/kafka/config/kafka_server_jaas.conf/opt/kafka/bin/kafka-topics.sh --list --zookeeper #.#.#.#:2181$ export KAFKA_OPTS=-Djava.security.auth.login.config=/opt/kafka/config/kafka_server_jaas.conf/opt/kafka/bin/kafka-topics.sh --delete --zookeeper #.#.#.#:2181 --topic discoveryTopic/opt/kafka/bin/kafka-topics.sh --delete --zookeeper #.#.#.#:2181 --topic monitoringTopic$ export KAFKA_OPTS=-Djava.security.auth.login.config=/opt/kafka/config/kafka_server_jaas.conf/opt/kafka/bin/kafka-topics.sh --create --zookeeper #.#.#.#:2181 --replication-factor 1 --partitions 1 --topic monitoringTopic/opt/kafka/bin/kafka-topics.sh --create --zookeeper #.#.#.#:2181 --replication-factor 1 --partitions 1 --topic discoveryTopic $ export KAFKA_OPTS=-Djava.security.auth.login.config=/opt/kafka/config/kafka_client_jaas.conf$ cd /opt/kafka/bin/$./kafka-console-consumer.sh --topic discoveryTopic -from-beginning --consumer.config=consumer.properties --bootstrap-server=<server_IP/name>:9092
$ ./kafka-view-discoveryTopic.sh | head