当前位置:   article > 正文

kafka滚动升级_kafka2升级到3版本

kafka2升级到3版本

生产环境kafka版本为kafka_2.13-2.8.1.tgz,因存在漏洞需将kafka版本升级至kafka_2.13-3.4.0.tgz以上版本。

IP地址kafkazookeeper节点
192.168.10.101broker0zookeeper
192.168.10.102broker1zookeeper
192.168.10.103broker2zookeeper

升级前验证zookeeper与kafka状态是否正常,使用kafka命令查看当前kafka集群的topic和版本号

/opt/hadoop/coer/kafka_2.13-2.8.1/bin/kafka-topics.sh --bootstrap-server 192.168.10.101:9092 --list
/opt/hadoop/coer/kafka_2.13-2.8.1/bin/kafka-topics.sh -version

在第一台broker上安装kafka_2.13-3.4.0版本的kafka,并启动新版本的kafka

  1. cd /opt/hadoop/core
  2. tar -zxvf kafka_2.13-3.4.0.tar.gz
  3. cp kafka_2.13-2.8.1/config/server.properties kafka_2.13-3.4.0/config
  4. cd kafka_2.13-3.4.0/config
  5. vi server.properties
  6. #添加下面这一行配置,这里的版本号,是你的旧版本,不是将要升级的新版本,即是我目前环境的旧版本2.8.1,如果我这里写成我想要升级的新版本3.4.0,那么就会出现最下面的异常报错。
  7. inter.broker.protocol.version=2.8-IV1
  8. #关闭kafka_2.13-2.8.1进程
  9. cd /opt/hadoop/core/kafka_2.13-2.8.1
  10. bin/kafka-server-stop.sh
  11. #启动kafka_2.13-3.4.0进程
  12. cd /opt/hadoop/core/kafka_2.13-3.4.0
  13. bin/kafka-server-start.sh -daemon config/server.properties
  14. #查看是否能正常访问集群
  15. /opt/hadoop/coer/kafka_2.13-3.4.0/bin/kafka-topics.sh --bootstrap-server --describe --topic topicname
  16. #同时可以查看config/server.properties中的配置,查看brokerid
  17. #访问zookeeper查看kafka是否加入集群
  18. zkCli.sh
  19. ls /kafka/broker/ids
  20. #查看日志,正常日志应该如下所示:
  21. [2024-06-21 15:02:48,940] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions HashSet(__consumer_offsets-8, __consumer_offsets-38, hello_test1-2, __consumer_offsets-26, __consumer_offsets-32, __consumer_offsets-2, __consumer_offsets-14, __consumer_offsets-20, __consumer_offsets-44) (kafka.server.ReplicaFetcherManager)
  22. [2024-06-21 15:02:48,958] INFO [GroupCoordinator 0]: Elected as the group coordinator for partition 2 in epoch 28 (kafka.coordinator.group.GroupCoordinator)
  23. [2024-06-21 15:02:48,958] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-2 for epoch 28 (kafka.coordinator.group.GroupMetadataManager)
  24. [2024-06-21 15:02:48,958] INFO [GroupCoordinator 0]: Elected as the group coordinator for partition 20 in epoch 28 (kafka.coordinator.group.GroupCoordinator)
  25. [2024-06-21 15:02:48,958] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-20 for epoch 28 (kafka.coordinator.group.GroupMetadataManager)
  26. [2024-06-21 15:02:48,958] INFO [GroupCoordinator 0]: Elected as the group coordinator for partition 38 in epoch 28 (kafka.coordinator.group.GroupCoordinator)
  27. [2024-06-21 15:02:48,958] INFO [GroupMetadataManager brokerId=0] Scheduling loading of offsets and group metadata from __consumer_offsets-38 for epoch 28 (kafka.coordinator.group.GroupMetadataManager)
  28. #可能会出下下面这种异常日志:
  29. java.io.IOException: Connection to 2 was disconnected before the response was read
  30. at org.apache.kafka.clients.NetworkClientUtils.sendAndReceive(NetworkClientUtils.java:99)
  31. at kafka.server.BrokerBlockingSender.sendRequest(BrokerBlockingSender.scala:113)
  32. at kafka.server.RemoteLeaderEndPoint.fetch(RemoteLeaderEndPoint.scala:78)
  33. at kafka.server.AbstractFetcherThread.processFetchRequest(AbstractFetcherThread.scala:309)
  34. at kafka.server.AbstractFetcherThread.$anonfun$maybeFetch$3(AbstractFetcherThread.scala:124)
  35. at kafka.server.AbstractFetcherThread.$anonfun$maybeFetch$3$adapted(AbstractFetcherThread.scala:123)
  36. at scala.Option.foreach(Option.scala:437)
  37. at kafka.server.AbstractFetcherThread.maybeFetch(AbstractFetcherThread.scala:123)
  38. at kafka.server.AbstractFetcherThread.doWork(AbstractFetcherThread.scala:106)
  39. at kafka.server.ReplicaFetcherThread.doWork(ReplicaFetcherThread.scala:97)
  40. at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:96)

 逐一对3台kafka进行升级,先停止旧版本的kafka,再启动新版本的kafka,完成滚动升级。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/942563
推荐阅读
相关标签
  

闽ICP备14008679号