https://kafka.apache.org/quickstart
https://kafka.apache.org/downloads
https://dlcdn.apache.org/kafka/3.9.1/kafka_2.13-3.9.1.tgz
wget https://dlcdn.apache.org/kafka/3.9.1/kafka_2.13-3.9.1.tgz
tar -zxvf kafka_2.13-3.9.1.tgz
mv kafka_2.13-3.9.1 kafka
生成集群ID
KAFKA_CLUSTER_ID=$(/usr/local/kafka/bin/kafka-storage.sh random-uuid)
echo "Using cluster ID: $KAFKA_CLUSTER_ID"
格式化存储目录
/usr/local/kafka/bin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c /usr/local/kafka/config/kraft/server.properties
启动 Kafka
/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/kraft/server.properties
创建topic
./bin/kafka-topics.sh --create --topic topic-example --bootstrap-server localhost:9092
查看topic信息
./bin/kafka-topics.sh --describe --topic topic-example --bootstrap-server localhost:9092
生产消息
./bin/kafka-console-producer.sh --topic topic-example --bootstrap-server localhost:9092
消费消息
./bin/kafka-console-consumer.sh --topic topic-example --from-beginning --bootstrap-server localhost:9092