Apache Spark错误:无法连接到akka.tcp:// sparkMaster @

Fan*_*oos 9 hadoop cloudera apache-spark

这是我们使用apache spark和hadoop等大数据的第一步.

我们安装了Cloudera CDH 5.3.从cloudera经理我们选择安装spark.Spark在集群中的一个节点中启动并运行良好.

从我的机器上我做了一个连接的小应用程序来读取存储在hadoop HDFS上的文本文件.

我试图从Eclipse运行应用程序,它显示这些消息

15/02/11 14:44:01 INFO client.AppClient$ClientActor: Connecting to master spark://10.62.82.21:7077... 15/02/11 14:44:02 WARN client.AppClient$ClientActor: Could not connect to akka.tcp://sparkMaster@10.62.82.21:7077: akka.remote.InvalidAssociation: Invalid address: akka.tcp://sparkMaster@10.62.82.21:7077 15/02/11 14:44:02 WARN Remoting: Tried to associate with unreachable remote address [akka.tcp://sparkMaster@10.62.82.21:7077]. Address is now gated for 5000 ms, all messages to this address will be delivered to dead letters. Reason: Connection refused: no further information: /10.62.82.21:7077

应用程序有一个类使用以下行创建上下文

JavaSparkContext sc = new JavaSparkContext(new SparkConf().setAppName("Spark Count").setMaster("spark://10.62.82.21:7077"));

这个IP是机器火花工作的IP.

然后我尝试使用以下行从HDFS读取文件

sc.textFile("hdfs://10.62.82.21/tmp/words.txt")

当我运行应用程序时,我得到了

G Q*_*ana 6

检查你的Spark主日志,你应该看到类似的东西:

15/02/11 13:37:14 INFO Remoting: Remoting started; listening on addresses :[akka.tcp://sparkMaster@mymaster:7077]
15/02/11 13:37:14 INFO Remoting: Remoting now listens on addresses: [akka.tcp://sparkMaster@mymaster:7077]
15/02/11 13:37:14 INFO Master: Starting Spark master at spark://mymaster:7077
Run Code Online (Sandbox Code Playgroud)

然后,当您连接到主服务器时,请确保使用与上述日志中完全相同的主机名(不要使用IP地址):

.setMaster("spark://mymaster:7077"));
Run Code Online (Sandbox Code Playgroud)

Spark standalone对这个主机名/ IP的东西有点挑剔.