【问题标题】:Spark Socket Timeout issue while writing to hdfs写入 hdfs 时出现 Spark Socket 超时问题
【发布时间】:2016-05-22 01:32:57
【问题描述】:

我正在尝试处理配置单元查询并以 ORC 格式写入 HDFS。但是我遇到了超时问题。我检查了 spark-default.conf ,但没有超时设置,我应该添加它吗?请告诉我要进行的更改

temp = sqlContext.sql(""" query """)
temp.write.format("orc").option("header", "true").save("hdfs://app/Quality/spark_test/")

附上错误日志

: org.apache.hadoop.net.ConnectTimeoutException: Call From .. to app:8020 failed on socket timeout exception: org.apache.hadoop.net.ConnectTimeoutException: 20000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=app/64.100.51.136:8020]; For more details see:  http://wiki.apache.org/hadoop/SocketTimeout
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.apache.hadoop.net.NetUtils.wrapWithMessage(NetUtils.java:792)
    at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:751)
    at org.apache.hadoop.ipc.Client.call(Client.java:1482)
    at org.apache.hadoop.ipc.Client.call(Client.java:1409)
    at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:229)
    at com.sun.proxy.$Proxy46.getFileInfo(Unknown Source)
    at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getFileInfo(ClientNamenodeProtocolTranslatorPB.java:771)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:187)
    at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)
    at com.sun.proxy.$Proxy47.getFileInfo(Unknown Source)
    at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:2113)
    at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1305)
    at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1301)
    at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
    at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1301)
    at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1460)
    at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelation.run(InsertIntoHadoopFsRelation.scala:73)
    at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult$lzycompute(commands.scala:58)
    at org.apache.spark.sql.execution.ExecutedCommand.sideEffectResult(commands.scala:56)
    at org.apache.spark.sql.execution.ExecutedCommand.doExecute(commands.scala:70)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:132)
    at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$5.apply(SparkPlan.scala:130)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150)
    at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:130)
    at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:55)
    at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:55)
    at org.apache.spark.sql.execution.datasources.ResolvedDataSource$.apply(ResolvedDataSource.scala:256)
    at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:148)
    at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:139)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:381)
    at py4j.Gateway.invoke(Gateway.java:259)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:209)
    at java.lang.Thread.run(Thread.java:744)

原因:org.apache.hadoop.net.ConnectTimeoutException:等待通道准备好连接时超时 20000 毫秒。 ch : java.nio.channels.SocketChannel[连接挂起远程=app/64.100.51.136:8020] 在 org.apache.hadoop.net.NetUtils.connect(NetUtils.java:534) 在 org.apache.hadoop.net.NetUtils.connect(NetUtils.java:495) 在 org.apache.hadoop.ipc.Client$Connection.setupConnection(Client.java:614) 在 org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:708) 在 org.apache.hadoop.ipc.Client$Connection.access$2900(Client.java:374) 在 org.apache.hadoop.ipc.Client.getConnection(Client.java:1531) 在 org.apache.hadoop.ipc.Client.call(Client.java:1448) ... 41 更多

【问题讨论】:

  • 看起来您的连接本身存在问题。你有成功写过东西吗?尝试一个小文件。

标签: hadoop apache-spark hive timeout hdfs


【解决方案1】:

问题来自于错误提供的 hdfs 位置。当您提供hdfs://app/ 时,spark 将假定namenode 主机名是app

所以要解决这个问题:在您的代码中,当您提供 hdfs 位置时,您应该:

  1. 提供名称节点的主机名/或 IP,因此您的代码应该是:

    temp.write.format("orc").option("header", "true").save("hdfs://NAMENODE_HOST:8020/app/Quality/spark_test/")
    
  2. 或者,如果您已经使用 HDFS/Yarn 配置了 Spark,则通过在 spark-env.sh 中设置配置文件的位置,在没有协议 (hdfs) 的情况下提供 HDFS 上的位置,因此代码将是:

    temp.write.format("orc").option("header", "true").save("/app/Quality/spark_test/")
    

【讨论】:

    猜你喜欢
    • 2018-12-25
    • 1970-01-01
    • 2017-12-07
    • 2019-07-12
    • 1970-01-01
    • 1970-01-01
    • 2010-11-18
    • 1970-01-01
    • 2018-01-30
    相关资源
    最近更新 更多