Kafka版本升级Linux环境注意事项
log.dirs指定路径)、配置文件(server.properties、zookeeper.properties等)及日志文件(/var/log/kafka/)。可使用rsync或tar工具,避免升级过程中数据丢失。kafka-topics.sh --describe查看)、无Broker宕机,且ZooKeeper集群正常运行。systemctl stop kafka或kill -15 <PID>(而非kill -9)停止Broker,确保Broker主动将Leader角色转移至其他副本,减少数据抖动。server.properties中的关键配置:
inter.broker.protocol.version:设置为旧版本协议(如从3.0升级到3.3,设为3.0),升级完成后逐步升级至新版本;log.message.format.version:同理,设为旧版本协议;listeners/advertised.listeners:更新Broker监听地址(如新增IP或端口);unclean.leader.election.enable:必须设为false(禁止非同步副本成为Leader,保障数据一致性)。tail -f /var/log/kafka/server.log)确认无错误信息;使用kafka-broker-api-versions.sh --bootstrap-server localhost:9092验证Broker版本是否为新版本。# 创建测试Topic
kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test_topic
# 生产者发送消息
kafka-console-producer.sh --broker-list localhost:9092 --topic test_topic
# 消费者接收消息
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test_topic --from-beginning
确认消息能正常收发。