【kafka报错】java.lang.NoSuchMethodError: org.apache.zookeeper.ZooKeeper.<init>

kafka启动时报错内容:

java.lang.NoSuchMethodError: org.apache.zookeeper.ZooKeeper.(Ljava/lang/String;ILorg/apache/zookeeper/Watcher;Lorg/apache/zookeeper/client/ZKClientConfig;)V
        at kafka.zookeeper.ZooKeeperClient.(ZooKeeperClient.scala:117) ~[kafka_2.12-2.8.1.jar:?]
        at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1948) ~[kafka_2.12-2.8.1.jar:?]
        at kafka.server.KafkaServer.createZkClient$1(KafkaServer.scala:431) ~[kafka_2.12-2.8.1.jar:?]
        at kafka.server.KafkaServer.initZkClient(KafkaServer.scala:456) [kafka_2.12-2.8.1.jar:?]
        at kafka.server.KafkaServer.startup(KafkaServer.scala:191) [kafka_2.12-2.8.1.jar:?]
        at kafka.Kafka$.main(Kafka.scala:109) [kafka_2.12-2.8.1.jar:?]
        at kafka.Kafka.main(Kafka.scala) [kafka_2.12-2.8.1.jar:?]
2022-10-07T16:58:35,167 INFO [main] kafka.server.KafkaServer - shutting down
2022-10-07T16:58:35,194 INFO [main] org.apache.kafka.common.utils.AppInfoParser - App info kafka.server for 10 unregistered
2022-10-07T16:58:35,199 INFO [main] kafka.server.KafkaServer - shut down completed
2022-10-07T16:58:35,200 ERROR [main] kafka.Kafka$ - Exiting Kafka.
2022-10-07T16:58:35,202 INFO [kafka-shutdown-hook] kafka.server.KafkaServer - shutting down

报错原因:
zookeeper的jar包冲突,不一定是kafka中的jar包冲突,我这里是因为hive中有一个低版本的zookeeper jar包

问题定位过程:
1.查看kafka的日志

less logs/kafkaServer.out | grep zookeeper


发现连接的zookeeper版本是3.4.6,但我服务器上安装的zookeeper版本是3.6.3,导致zookeeper版本冲突
在这里插入图片描述
解决办法:
找到对应的jar包,用zookeeper lib目录下的jar包进行替换,再启动kafka

你可能感兴趣的:(大数据相关,常见错误,kafka)