
升级前注意做好集群的备份一、解压sudosu-tar-zxvfkafka_2.12-3.8.1.tgzsudoln-s/opt/kafka_2.12-3.8.1 /opt/kafka二、配置server.propertieshostname -i 获取本机ip 修改配置文件中/opt/kafka/conf/server.properties 中的localhost为本机ip如下图有两处需要修改hostname-ivim/opt/kafka/conf/server.properties三、集群初始化# 产生集群IDKAFKA_CLUSTER_ID$(/opt/kafka/bin/kafka-storage.sh random-uuid)# 格式化集群/opt/kafka/bin/kafka-storage.shformat-t$KAFKA_CLUSTER_ID-c/opt/kafka/config/kraft/server.properties# 格式化日志# Formatting /tmp/kraft-combined-logs with metadata.version 3.8-IV0.四、启动kafkanohup/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/kraft/server.properties/opt/kafka/kafka-server.log21测试kafka是否正常# 创建一个topic/opt/kafka/bin/kafka-topics.sh--create--topicquickstart-events --bootstrap-server localhost:9092# 查看topic描述/opt/kafka/bin/kafka-topics.sh--describe--topicquickstart-events --bootstrap-server localhost:9092# 生产一些数据/opt/kafka/bin/kafka-console-producer.sh--topicquickstart-events --bootstrap-server localhost:9092111222# 消费数据/opt/kafka/bin/kafka-console-consumer.sh--topicquickstart-events --from-beginning --bootstrap-server localhost:9092111222五、创建topic/opt/kafka/bin/kafka-topics.sh--create--bootstrap-server localhost:9092 --replication-factor1--partitions1--if-not-exists--topica1查看topic/opt/kafka/bin/kafka-topics.sh--describe--topica1 --bootstrap-server localhost:9092 Topic: a1 TopicId: Dhxy7-NES7ujY_5kfdMe3Q PartitionCount:1ReplicationFactor:1Configs:segment.bytes1073741824Topic: mg_auditlog2_pro Partition:0Leader:1Replicas:1Isr:1Elr: LastKnownElr:六、验证/opt/kafka/bin/kafka-topics.sh--list--bootstrap-server ip:9092 /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server ip:9092--topica1 --from-beginning