Home >System Tutorial >LINUX >Share detailed tutorials on installing Kafka under Linux
1. Prerequisites
2. Install Java
sudo apt-get update sudo apt-get install openjdk-8-jdk
3. Install Apache Kafka
wget https://dlcdn.apache.org/kafka/2.13/kafka_2.13-3.3.1.tgz tar -xvzf kafka_2.13-3.3.1.tgz
4. Install ZooKeeper
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz tar -xvzf zookeeper-3.4.14.tar.gz
5. Configure Kafka
cd kafka_2.13-3.3.1 cp config/server.properties config/server.properties.orig vim config/server.properties
Modify the following configuration:
broker.id=0 listeners=PLAINTEXT://localhost:9092 zookeeper.connect=localhost:2181
6. Configure ZooKeeper
cd zookeeper-3.4.14 cp conf/zoo.cfg conf/zoo.cfg.orig vim conf/zoo.cfg
Modify the following configuration:
dataDir=/tmp/zookeeper clientPort=2181
7. Start ZooKeeper
cd zookeeper-3.4.14 bin/zkServer.sh start
8. Start Kafka
cd kafka_2.13-3.3.1 bin/kafka-server-start.sh config/server.properties
9. Create Topic
bin/kafka-topics.sh --create --topic my-topic --partitions 1 --replication-factor 1
10. Send message
bin/kafka-console-producer.sh --topic my-topic --message "Hello, world!"
11. Consume message
bin/kafka-console-consumer.sh --topic my-topic --from-beginning
12. Stop Kafka
bin/kafka-server-stop.sh
13. Stop ZooKeeper
bin/zkServer.sh stop
The above is the detailed content of Share detailed tutorials on installing Kafka under Linux. For more information, please follow other related articles on the PHP Chinese website!