出现问题:找不到 leader offset
py4j.protocol.Py4JJavaError: An error occurred while calling o41.createDirectStreamWithoutMessageHandler.
: org.apache.spark.SparkException: java.nio.channels.ClosedChannelException
java.nio.channels.ClosedChannelException
java.nio.channels.ClosedChannelException
org.apache.spark.SparkException: Couldn't find leader offsets for Set([test,0], [test,1], [test,2])
通过整理:网上有两种说法,加上自己自己遇到的一种,目前整理出3种
(1)自己目前遇到的问题,kafka的broker地址如下
brokers = "192.168.5.180:9092,192.168.5.181:9092,192.168.5.182:9092"
或者
brokers = "kafka-node1:9092,kafka-node2:9092,kafka-node3:9092"
这两种写法,都会报上面的错误:(没弄个明白,为甚么直接写ip还要报错,真的郁闷)
上述两种写法解决办法:修改windows本地hosts,加上域名映射
目录地址:C:\Windows\System32\drivers\etc\hosts
添加:
192.168.5.180 kafka-node1
192.168.5.181 kafka-node2
192.168.5.182 kafka-node3
(2)检查自己的kafka中topic,是否为空,当为空时,报错
(3)num.replica.fetchers的问题,参考下面文章
https://blog.csdn.net/yanshu2012/article/details/53995159