spark streaming kafka : Unknown error fetching data for topic-partition

自作多情 提交于 2021-01-29 10:31:12

问题


I'm trying to read a Kafka topic from a Spark cluster using Structured Streaming API with Kafka integration in Spark

val sparkSession = SparkSession.builder()
  .master("local[*]")
  .appName("some-app")
  .getOrCreate()

Kafka stream creation

import sparkSession.implicits._

val dataFrame = sparkSession
  .readStream
  .format("kafka")
  .option("subscribepattern", "preprod-*")
  .option("kafka.bootstrap.servers", "<brokerUrl>:9094")
  .option("kafka.ssl.protocol", "TLS")
  .option("kafka.security.protocol", "SSL")
  .option("kafka.ssl.key.password", secretPassword)
  .option("kafka.ssl.keystore.location", "/tmp/xyz.jks")
  .option("kafka.ssl.keystore.password", secretPassword)
  .option("kafka.ssl.truststore.location", "/abc.jks")
  .option("kafka.ssl.truststore.password", secretPassword)
  .load()
  .selectExpr("CAST(key AS STRING)", "CAST(value AS STRING)")
  .as[(String, String)]
  .writeStream
  .format("console")
  .start()
  .awaitTermination()

running it using the command

/usr/local/spark/bin/spark-submit 
--packages "org.apache.spark:spark-streaming-kafka-0-10_2.11:2.3.1,org.apache.spark:spark-sql-kafka-0-10_2.11:2.3.1"
myjar.jar

Getting the below error

    2018-09-28 07:29:23 INFO  AbstractCoordinator:505 - Discovered coordinator brokerUrl.com:32400 (id: 2147483647 rack: null) for group spark-kafka-source-c72dcb79-f3bc-4dfd-86a5-9d14be48fa04-1188588017-executor.
2018-09-28 07:29:23 INFO  AbstractCoordinator:505 - Discovered coordinator brokerUrl.com:32400 (id: 2147483647 rack: null) for group spark-kafka-source-c72dcb79-f3bc-4dfd-86a5-9d14be48fa04-1188588017-executor.
2018-09-28 07:29:23 INFO  AbstractCoordinator:505 - Discovered coordinator brokerUrl.com:32400 (id: 2147483647 rack: null) for group spark-kafka-source-c72dcb79-f3bc-4dfd-86a5-9d14be48fa04-1188588017-executor.
2018-09-28 07:29:23 INFO  AbstractCoordinator:505 - Discovered coordinator brokerUrl.com:32400 (id: 2147483647 rack: null) for group spark-kafka-source-c72dcb79-f3bc-4dfd-86a5-9d14be48fa04-1188588017-executor.
2018-09-28 07:29:47 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-5
2018-09-28 07:30:25 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-7
2018-09-28 07:30:27 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-7
2018-09-28 07:30:27 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-5
2018-09-28 07:30:50 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-8
2018-09-28 07:30:50 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-4
2018-09-28 07:30:50 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-7
2018-09-28 07:30:50 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-8
2018-09-28 07:30:50 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-4
2018-09-28 07:30:50 WARN  Fetcher:594 - Unknown error fetching data for topic-partition preprod-sanity-test-5
.....
....
so on

回答1:


What's your Kafka broker version? And how did you generate these messages?

If these messages have headers (https://issues.apache.org/jira/browse/KAFKA-4208), you will need to use Kafka 0.11+ to consume them as old Kafka client cannot read such messages. If so, you can use the following command:

/usr/local/spark/bin/spark-submit --packages "org.apache.kafka:kafka-clients:0.11.0.3,org.apache.spark:spark-sql-kafka-0-10_2.11:2.3.1"
myjar.jar


来源:https://stackoverflow.com/questions/52550777/spark-streaming-kafka-unknown-error-fetching-data-for-topic-partition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!