在开始安装之前,你需要确保你的系统满足以下要求:
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中文网其他相关文章!