spark on yarn cluster模式,异常:NoSuchMethodError: org.apache.kafka.clients.consumer.KafkaConsumer

异常出现

NoSuchMethodError: org.apache.kafka.clients.consumer.KafkaConsumer
我们可以看到在org.apache.spark.streaming.kafka010.InternalKafkaConsumer找不到对应的类

解决方法:

因为spark对应kafka有版本要求,我们在CDH的spark中搜索kafka
spark on yarn cluster模式,异常:NoSuchMethodError: org.apache.kafka.clients.consumer.KafkaConsumer_第1张图片
然后选择0.10
保存之后,然后重启下Spark
spark on yarn cluster模式,异常:NoSuchMethodError: org.apache.kafka.clients.consumer.KafkaConsumer_第2张图片
spark on yarn cluster模式,异常:NoSuchMethodError: org.apache.kafka.clients.consumer.KafkaConsumer_第3张图片
部署之后,重新执行命令

spark2-submit \
--master yarn \
--deploy-mode cluster \
--class com.bigdata.PreWarningScalaAppV2 \
--jars /var/lib/hadoop-hdfs/converter-moshi-2.1.0.jar,/var/lib/hadoop-hdfs/fastjson-1.2.58.jar,/var/lib/hadoop-hdfs/guava-20.0.jar,/var/lib/hadoop-hdfs/influxdb-java-2.5.jar,file:/var/lib/hadoop-hdfs/kafka-clients-2.0.0.jar,file:/var/lib/hadoop-hdfs/logging-interceptor-3.5.0.jar,file:/var/lib/hadoop-hdfs/moshi-1.2.0.jar,file:/var/lib/hadoop-hdfs/okhttp-3.5.0.jar,file:/var/lib/hadoop-hdfs/okio-1.11.0.jar,file:/var/lib/hadoop-hdfs/retrofit-2.1.0.jar,file:/var/lib/hadoop-hdfs/spark-streaming-kafka-0-10_2.11-2.4.4.jar,file:/var/lib/hadoop-hdfs/mysql-connector-java-5.1.48.jar \
--conf "spark.driver.userClassPathFirst=true" \
/var/lib/hadoop-hdfs/prewarning-1.0.jar

显示运行ok
spark on yarn cluster模式,异常:NoSuchMethodError: org.apache.kafka.clients.consumer.KafkaConsumer_第4张图片

你可能感兴趣的:(CDH)