Spark 流和 Kafka 集成

Spark streaming and Kafka intergration

我是 Apache Spark 的新手,我一直在做一个与 twitter 数据的情绪分析相关的项目,其中涉及 spark 流和 kafka 集成。我一直在关注 github 代码(下面提供的 link)

https://github.com/sridharswamy/Twitter-Sentiment-Analysis-Using-Spark-Streaming-And-Kafka 但是在最后阶段,也就是Kafka与Apache Spark集成的过程中,出现了如下错误

py4j.protocol.Py4JError: An error occurred while calling o24.createDirectStreamWithoutMessageHandler. Trace:
py4j.Py4JException: Method createDirectStreamWithoutMessageHandler([class org.apache.spark.streaming.api.java.JavaStreamingContext, class java.util.HashMap, class java.util.HashSet, class java.util.HashMap]) does not exist
    at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
    at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
    at py4j.Gateway.invoke(Gateway.java:272)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:214)
    at java.lang.Thread.run(Thread.java:745)

使用的命令:bin/spark-submit --packages org.apache.spark:spark-streaming-kafka_2.10:1.5.1 twitterStream.py

Apache Spark 版本:spark-2.1.0-bin-hadoop2.4

卡夫卡版本:kafka_2.11-0.10.1.1

我无法对此进行调试,如有任何帮助,我们将不胜感激。

您尝试 运行 的示例是为 运行ning 在 spark 1.5 中设计的。您应该从 spark 2.1.0 下载 spark 1.5 或 运行 spark-submit,但使用与 2.1.0 相关的 kafka 包,例如: ./bin/spark-submit --packages org.apache.spark:spark-streaming-kafka-0-8_2.11:2.1.0.