无法连接到远程 Spark Master - ROR TransportRequestHandler:为单向消息调用 RpcHandler#receive() 时出错

And*_*M16 1 scala cassandra apache-spark spark-cassandra-connector

我前段时间发布了这个问题,但结果发现我使用的是本地资源而不是远程资源。

我有一台配置了spark : 2.1.1cassandra : 3.0.9和的远程计算机scala : 2.11.6

Cassandra 的配置位置为localhost:9032,spark master 的配置位置为localhost:7077

Spark master 设置为127.0.0.1,其端口设置为7077

我可以远程连接到 cassandra,但无法使用 Spark 执行相同的操作。

连接到远程 Spark Master 时,出现以下错误:

错误 TransportRequestHandler:为单向消息调用 RpcHandler#receive() 时出错。

这是我通过代码进行的设置

val configuration = new SparkConf(true)
                        .setAppName("myApp")
                        .setMaster("spark://xx.xxx.xxx.xxx:7077")
                        .set("spark.cassandra.connection.host", "xx.xxx.xxx.xxx")
                        .set("spark.cassandra.connection.port", 9042)
                        .set("spark.cassandra.input.consistency.level","ONE")
                        .set("spark.driver.allowMultipleContexts", "true")
val sparkSession = SparkSession
                   .builder()
                   .appName("myAppEx")
                   .config(configuration)
                   .enableHiveSupport()
                   .getOrCreate()
Run Code Online (Sandbox Code Playgroud)

我不明白为什么 cassandra 工作得很好而 Spark 却不行。

这是什么原因造成的?我该如何解决?

And*_*M16 5

我回答这个问题是为了帮助其他遇到这个问题的人。

结果发现这是由于Intellij Idea的 scala 版本与服务器版本不匹配造成的。

scala ~ 2.11.6服务器在 IDE 使用时有scala ~ 2.11.8.

为了确保使用完全相同的版本,需要通过执行以下步骤来更改 IDE 的 scala 版本:

文件 > 项目结构 > + > Scala SDK > 查找并选择服务器的 scala 版本 > 如果尚未安装,请下载它 > 确定 > 应用 > 确定