无法绑定到: spark-master,使用具有两个工作节点的远程集群。

23

我正在努力使本地主服务器和两台远程工作机器都正常工作。现在,我想连接到一个拥有相同远程工作机器的远程主服务器。我已尝试不同的/etc/hosts设置组合以及互联网上的其他建议,但是没有任何效果。

主类是:

public static void main(String[] args) {
    ScalaInterface sInterface = new ScalaInterface(CHUNK_SIZE,
            "awsAccessKeyId",
            "awsSecretAccessKey");

    SparkConf conf = new SparkConf().setAppName("POC_JAVA_AND_SPARK")
            .setMaster("spark://spark-master:7077");

    org.apache.spark.SparkContext sc = new org.apache.spark.SparkContext(
            conf);

    sInterface.enableS3Connection(sc);
    org.apache.spark.rdd.RDD<Tuple2<Path, Text>> fileAndLine = (RDD<Tuple2<Path, Text>>) sInterface.getMappedRDD(sc, "s3n://somebucket/");

    org.apache.spark.rdd.RDD<String> pInfo = (RDD<String>) sInterface.mapPartitionsWithIndex(fileAndLine);

    JavaRDD<String> pInfoJ = pInfo.toJavaRDD();

    List<String> result = pInfoJ.collect();

    String miscInfo = sInterface.getMiscInfo(sc, pInfo);

    System.out.println(miscInfo);

}

它失败于:

List<String> result = pInfoJ.collect();

我遇到的错误是:

1354 [sparkDriver-akka.actor.default-dispatcher-3] ERROR akka.remote.transport.netty.NettyTransport  - failed to bind to spark-master/192.168.0.191:0, shutting down Netty transport
1354 [main] WARN  org.apache.spark.util.Utils  - Service 'sparkDriver' could not bind on port 0. Attempting port 1.
1355 [main] DEBUG org.apache.spark.util.AkkaUtils  - In createActorSystem, requireCookie is: off
1363 [sparkDriver-akka.actor.default-dispatcher-3] INFO  akka.remote.RemoteActorRefProvider$RemotingTerminator  - Shutting down remote daemon.
1364 [sparkDriver-akka.actor.default-dispatcher-3] INFO  akka.remote.RemoteActorRefProvider$RemotingTerminator  - Remote daemon shut down; proceeding with flushing remote transports.
1364 [sparkDriver-akka.actor.default-dispatcher-5] INFO  akka.remote.RemoteActorRefProvider$RemotingTerminator  - Remoting shut down.
1367 [sparkDriver-akka.actor.default-dispatcher-4] INFO  akka.event.slf4j.Slf4jLogger  - Slf4jLogger started
1370 [sparkDriver-akka.actor.default-dispatcher-6] INFO  Remoting  - Starting remoting
1380 [sparkDriver-akka.actor.default-dispatcher-4] ERROR akka.remote.transport.netty.NettyTransport  - failed to bind to spark-master/192.168.0.191:0, shutting down Netty transport
Exception in thread "main" 1382 [sparkDriver-akka.actor.default-dispatcher-6] INFO  akka.remote.RemoteActorRefProvider$RemotingTerminator  - Shutting down remote daemon.
1382 [sparkDriver-akka.actor.default-dispatcher-6] INFO  akka.remote.RemoteActorRefProvider$RemotingTerminator  - Remote daemon shut down; proceeding with flushing remote transports.
java.net.BindException: Failed to bind to: spark-master/192.168.0.191:0: Service 'sparkDriver' failed after 16 retries!
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:272)
    at akka.remote.transport.netty.NettyTransport$$anonfun$listen$1.apply(NettyTransport.scala:393)
    at akka.remote.transport.netty.NettyTransport$$anonfun$listen$1.apply(NettyTransport.scala:389)
    at scala.util.Success$$anonfun$map$1.apply(Try.scala:206)
    at scala.util.Try$.apply(Try.scala:161)
    at scala.util.Success.map(Try.scala:206)
    at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235)
    at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:235)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
    at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.processBatch$1(BatchingExecutor.scala:67)
    at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:82)
    at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.apply(BatchingExecutor.scala:59)
    at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.apply(BatchingExecutor.scala:59)
    at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)
    at akka.dispatch.BatchingExecutor$Batch.run(BatchingExecutor.scala:58)
    at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:41)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
1383 [sparkDriver-akka.actor.default-dispatcher-7] INFO  akka.remote.RemoteActorRefProvider$RemotingTerminator  - Remoting shut down.
1385 [delete Spark temp dirs] DEBUG org.apache.spark.util.Utils  - Shutdown hook called

非常感谢您的帮助!


没有一个答案能够帮到我,但出乎意料的是,关闭WiFi连接确实解决了我的问题。不过这其实是一种很烦人的解决方法! - 7kemZmani
4个回答

55

将环境变量 SPARK_LOCAL_IP=127.0.0.1 设置为解决了我的问题。


这对我也解决了问题。但是这是因为笔记本电脑上的ipv6。 - Jorge Machado

12

我的问题出在/etc/hosts文件将错误的IP地址映射到了我的本地主机名。

您日志中的BindException抱怨IP地址192.168.0.191。我认为它解析为您的机器的主机名,而不是实际使用的网络接口的IP地址。一旦您修复这个问题,它就应该可以正常工作了。


5

我在我的EC2实例中安装了Spark。我启动了一个新的web服务器,为了满足其要求,我必须将主机名更改为EC2公共DNS名称,即:

hostname ec2-54-xxx-xxx-xxx.compute-1.amazonaws.com

之后我的Spark无法工作,并显示以下错误:

16/09/20 21:02:22 WARN Utils: 服务'sparkDriver'无法绑定到端口0。尝试端口1。 16/09/20 21:02:22 ERROR SparkContext: 初始化SparkContext时出错。

我通过将SPARK_LOCAL_IP设置为以下值来解决它:

export SPARK_LOCAL_IP="localhost"

然后就可以像下面这样启动闪亮的Shell:
$SPARK_HOME/bin/spark-shell

我发布这个问题已经很久了,我猜可能在此期间有些事情发生了改变,使得有简单的解决方案。 - 3xCh1_23

1

我不想使用提交,我想通过IDE实现它。提交可以正常工作,并且Master设置为spark://spark-master:7077。 - 3xCh1_23
我在IDE中的做法是创建一个conf对象,并通过setMaster方法设置主节点。然后,使用conf对象创建Spark上下文。我相信Spark上下文是应用程序和集群之间的链接。 - ayan guha
这正是我做事的方式,也是我得到所提到错误的确切方式。 - 3xCh1_23
不行,因为许可证的原因。但我可以发布主类。 - 3xCh1_23

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接