我在伪分布式模式下运行hadoop1.2.1,namenode和datanode都在同一个虚拟机上。datanode有4个卷。我正在做一些关于在hadoop中使用非常小的块大小(4k,8k,…)的测试。复制因子设置为1。
将块大小设置为8k时,我可以使用以下方法将64mb文件复制到hdfs:
bin/hadoop fs -put my64mbfile .
尽管在运行命令时,我多次出现以下异常:
13/08/29 10:50:47 WARN hdfs.DFSClient: NotReplicatedYetException sleeping
/user/myuser/my64mbfile retries left 4
13/08/29 10:50:48 INFO hdfs.DFSClient: org.apache.hadoop.ipc.RemoteException:
org.apache.hadoop.hdfs.server.namenode.NotReplicatedYetException:
Not replicated yet:/user/myuser/my64mbfile
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock
(FSNamesystem.java:1905)
at org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock
(NameNode.java:783)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:587)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1432)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1428)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.
java:1190)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1426)
at org.apache.hadoop.ipc.Client.call(Client.java:1113)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:229)
at com.sun.proxy.$Proxy1.addBlock(Unknown Source)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
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:85)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke
(RetryInvocationHandler.java:62)
at com.sun.proxy.$Proxy1.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.locateFollowingBlock
(DFSClient.java:3720)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream
(DFSClient.java:3580)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2600
(DFSClient.java:2783)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run
(DFSClient.java:3023)
之后,我重新格式化并重新启动hadoop。
当我调用相同的命令,但块大小为4k时,我仍然得到上面的警告,最终我得到了这个错误(只有大约一半的文件被复制到hdfs之后):
13/08/29 11:32:38 WARN hdfs.DFSClient: Error Recovery for
blk_1692157315263473676_1009 bad datanode[0] nodes == null
13/08/29 11:32:38 WARN hdfs.DFSClient: Could not get block locations. Source
file "/user/myuser/my64mbfile" - Aborting...
put: java.io.IOException: java.lang.OutOfMemoryError: Requested array size
exceeds VM limit
13/08/29 11:32:38 ERROR hdfs.DFSClient: Failed to close file
/user/myuser/my64mbfile
org.apache.hadoop.ipc.RemoteException: java.io.IOException:
java.lang.OutOfMemoryError: Requested array size exceeds VM limit
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at java.io.DataOutputStream.writeLong(DataOutputStream.java:224)
at org.apache.hadoop.hdfs.protocol.Block.write(Block.java:134)
at org.apache.hadoop.io.ArrayWritable.write(ArrayWritable.java:98)
at org.apache.hadoop.hdfs.server.namenode.FSEditLog$EditLogFileOutputStream.
write(FSEditLog.java:184)
at org.apache.hadoop.hdfs.server.namenode.FSEditLog.logEdit(FSEditLog.java:
1138)
at org.apache.hadoop.hdfs.server.namenode.FSEditLog.logOpenFile(FSEditLog.
java:1299)
at org.apache.hadoop.hdfs.server.namenode.FSDirectory.persistBlocks
(FSDirectory.java:305)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock
(FSNamesystem.java:1947)
at org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock(NameNode.java:783)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:587)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1432)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1428)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.
java:1190)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1426)
at org.apache.hadoop.ipc.Client.call(Client.java:1113)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:229)
at com.sun.proxy.$Proxy1.addBlock(Unknown Source)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod
(RetryInvocationHandler.java:85)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke
(RetryInvocationHandler.java:62)
at com.sun.proxy.$Proxy1.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.locateFollowingBlock
(DFSClient.java:3720)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream
(DFSClient.java:3580)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2600
(DFSClient.java:2783)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run
(DFSClient.java:3023)
datanode可以处理的块的数量有限制吗?或者namenode对于对象的数量是否有其他限制(除了dfs.namenode.fs limits.max blocks per file)?
对于4k的情况,块的总量应该是16384块,这意味着每个卷约4100块,这意味着每个卷约8200个文件(包括元数据文件)。
1条答案
按热度按时间8aqjt8rx1#
namenode将整个文件到块的Map(blockmap)保存在内存中,因此如果您配置的块太小,则blockmap可能会变大,从而导致oome。看到hadoop的namenode的内存消耗了吗?