在開始安裝之前,你需要確保你的系統符合以下要求:
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
和clientPort
選項的值分別改為/var/lib/zookeeper
和2181
: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
你已經成功地在Linux 下安裝了Kafka。現在,你可以開始使用 Kafka 來建立分散式系統。
以上是逐步指南:在Linux系統下從頭開始安裝Kafka的詳細內容。更多資訊請關注PHP中文網其他相關文章!