SocketTimeoutException when running hadoop distcp

2019-09-06 20:15发布

问题:

I'm using hadoop distcp -update to copy directory from one HDFS cluster to different one. Sometime (pretty often) I get this kind of exception:

13/07/03 00:20:03 INFO tools.DistCp: srcPaths=[hdfs://HDFS1:51175/directory_X]
13/07/03 00:20:03 INFO tools.DistCp: destPath=hdfs://HDFS2:51175/directory_X
13/07/03 00:25:27 WARN hdfs.DFSClient: src=directory_X, datanodes[0].getName()=***.***.***.***:8550
java.net.SocketTimeoutException: 69000 millis timeout while waiting for channel to be ready for read. ch : java.nio.channels.SocketChannel[connected local=/***.***.***.***:35872 remote=/***.***.***.***:8550]
        at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:164)
        at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:155)
        at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:128)
        at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:116)
        at java.io.DataInputStream.readShort(DataInputStream.java:295)
        at org.apache.hadoop.hdfs.DFSClient.getFileChecksum(DFSClient.java:885)
        at org.apache.hadoop.hdfs.DFSClient.getFileChecksum(DFSClient.java:822)
        at org.apache.hadoop.hdfs.DistributedFileSystem.getFileChecksum(DistributedFileSystem.java:541)
        at org.apache.hadoop.hdfs.DistributedFileSystem.getFileChecksum(DistributedFileSystem.java:53)
        at org.apache.hadoop.tools.DistCp.sameFile(DistCp.java:1230)
        at org.apache.hadoop.tools.DistCp.setup(DistCp.java:1110)
        at org.apache.hadoop.tools.DistCp.copy(DistCp.java:666)
        at org.apache.hadoop.tools.DistCp.run(DistCp.java:881)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
        at org.apache.hadoop.tools.DistCp.main(DistCp.java:908)
13/07/03 00:26:40 INFO tools.DistCp: sourcePathsCount=8542
13/07/03 00:26:40 INFO tools.DistCp: filesToCopyCount=0
13/07/03 00:26:40 INFO tools.DistCp: bytesToCopyCount=0.0

Does anyone has any idea what could it be? Using Hadoop 0.20.205.0

回答1:

Suggest to increase timeouts for both dfs.socket.timeout, for read timeout. And dfs.datanode.socket.write.timeout, for write timeout.

Default:

// Timeouts for communicating with DataNode for streaming writes/reads
public static int READ_TIMEOUT = 60 * 1000; // here, 69000 millis > 60000
public static int WRITE_TIMEOUT = 8 * 60 * 1000;

Add below in your hadoop-site.xml or hdfs-site.xml

<property>
  <name>dfs.datanode.socket.write.timeout</name>
  <value>3000000</value>
</property>

<property>
  <name>dfs.socket.timeout</name>
  <value>3000000</value>
</property>

Hope that helps.



回答2:

I think you also want to set dfs.client.socket-timeout



回答3:

Here is why.

Deprecated property name -> New property name

dfs.socket.timeout ->dfs.client.socket-timeout