How Do You Set Up Apache Kafka on Any Distribution of Linux?

Problem scenario
You want to set up Apache Kafka with a single broker just to test out. How do you do this on any distribution of Linux?

Prerequisite
You must install Zookeeper. If you need assistance, see this posting.

You may want to install screen because this solution will rely on it; you could open duplicate terminals instead of using the screen command.

Have Zookeeper running before you run the [Kafka installation] script below.

Procedures

portion=2.8.0
kafkaversion=2.12-$portion
curl -Ls https://ftp.wayne.edu/apache/kafka/2.4.1/kafka_$kafkaversion.tgz > /tmp/kafka_$kafkaversion.tgz
cd /bin/
cp /tmp/kafka_$kafkaversion.tgz .
sudo tar -zxf kafka_$kafkaversion.tgz
cd kafka_$kafkaversion/bin
./kafka-server-start.sh -daemon /root/kafka/config/server.properties
./kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
./kafka-topics.sh -list --bootstrap-server localhost:9092
echo "Kafka should be installed now"
echo 'Run this command:
./kafka-console-producer.sh --broker-list localhost:9092 --topic test
echo "go to another terminal"
and then enter some text'
echo " "
echo 'Start a new terminal, and run this command:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning'

Leave a comment

Your email address will not be published. Required fields are marked *