10.X
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.properties
listeners=SASL_PLAINTEXT://#.#.#.#:9092
zookeeper.connect=#.#.#.#: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 9092
The below output shows that there is a java process listening indicating good results.
tcp6 0 0 :::9092 :::* LISTEN 52922/java
Check to see if zookeeper process is listening to port 2181
$ sudo netstat -anp | grep 2181
The below output shows that there is a java process listening indicating good results.
tcp6 0 0 10.10.77.21:2181 :::* LISTEN 52926/java
Best 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 status kafka? kafka.service
/var/log/messages:Dec 19 17:33:43 rpc11845 systemd: Stopping kafka.service...
Dec 19 17:33:43 rpc11845 zookeeper-server-start.sh: [2019-12-19 17:33:43,586] INFO Processed session termination for sessionid: 0x100b5e538cf0003 (org.apache.zookeeper.server.PrepRequestProcessor)
Dec 19 17:33:43 rpc11845 zookeeper-server-start.sh: [2019-12-19 17:33:43,589] INFO Closed socket connection for client /10.10.77.21:49764 which had sessionid 0x100b5e538cf0003 (org.apache.zookeeper.server.NIOServerCnxn)
Dec 19 17:33:44 rpc11845 zookeeper-server-start.sh: [2019-12-19 17:33:44,179] INFO Processed session termination for sessionid: 0x100b5e538cf0002 (org.apache.zookeeper.server.PrepRequestProcessor)
Dec 19 17:33:44 rpc11845 zookeeper-server-start.sh: [2019-12-19 17:33:44,181] INFO Closed socket connection for client /10.10.77.21:49662 which had sessionid 0x100b5e538cf0002 (org.apache.zookeeper.server.NIOServerCnxn)
Dec 19 17:33:46 rpc11845 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 localhost:2181$ export KAFKA_OPTS=-Djava.security.auth.login.config=/opt/kafka/config/kafka_server_jaas.conf/opt/kafka/bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic discoveryTopic/opt/kafka/bin/kafka-topics.sh --delete --zookeeper localhost: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 localhost:2181 --replication-factor 1 --partitions 1 --topic monitoringTopic/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost: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