Before starting the installation, you need to ensure that your system meets the following requirements:
sudo apt-get update
sudo apt-get install openjdk-8-jdk
java -version
wget https://mirrors.estointernet.in/apache/zookeeper/zookeeper-3.6.3/zookeeper-3.6.3.tar.gz
tar -xzvf zookeeper-3.6.3.tar.gz
sudo mv zookeeper-3.6.3 /opt/zookeeper
sudo groupadd zookeeper sudo useradd -g zookeeper zookeeper
sudo chown -R zookeeper:zookeeper /opt/zookeeper
sudo nano /opt/zookeeper/conf/zoo.cfg
dataDir
and clientPort
options to /var/lib/zookeeper
and 2181
respectively: dataDir=/var/lib/zookeeper clientPort=2181
sudo mkdir -p /var/lib/zookeeper sudo chown -R zookeeper:zookeeper /var/lib/zookeeper
sudo /opt/zookeeper/bin/zkServer.sh start
sudo netstat -plnt | grep 2181
wget https://mirrors.estointernet.in/apache/kafka/2.8.1/kafka_2.13-2.8.1.tgz
tar -xzvf kafka_2.13-2.8.1.tgz
sudo mv kafka_2.13-2.8.1 /opt/kafka
sudo groupadd kafka sudo useradd -g kafka kafka
sudo chown -R kafka:kafka /opt/kafka
sudo nano /opt/kafka/config/server.properties
broker.id=0 listeners=PLAINTEXT://:9092 zookeeper.connect=localhost:2181
sudo mkdir -p /var/lib/kafka sudo chown -R kafka:kafka /var/lib/kafka
sudo /opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties
sudo netstat -plnt | grep 9092
kafka-topics --create --topic test --partitions 1 --replication-factor 1
kafka-console-producer --topic test --message "Hello, world!"
kafka-console-consumer --topic test --from-beginning
You have successfully installed Kafka under Linux. Now, you can start building distributed systems using Kafka.
The above is the detailed content of Step-by-step guide: Installing Kafka from scratch on Linux. For more information, please follow other related articles on the PHP Chinese website!