我正按照Michael Noll's tutorial在我的计算机上实现Hadoop单节点群集,并遇到了数据复制错误:
以下是完整的错误消息:
> hadoop@laptop:~/hadoop$ bin/hadoop dfs -copyFromLocal > tmp/testfiles testfiles > > 12/05/04 16:18:41 WARN hdfs.DFSClient: DataStreamer Exception: > org.apache.hadoop.ipc.RemoteException: java.io.IOException: File > /user/hadoop/testfiles/testfiles/file1.txt could only be replicated to > 0 nodes, instead of 1 at > org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:1271) > at > org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock(NameNode.java:422) > at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source) at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) at > org.apache.hadoop.ipc.RPC$Server.call(RPC.java:508) at > org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:959) at > org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:955) at > java.security.AccessController.doPrivileged(Native Method) at > javax.security.auth.Subject.doAs(Subject.java:396) at > org.apache.hadoop.ipc.Server$Handler.run(Server.java:953) > > at org.apache.hadoop.ipc.Client.call(Client.java:740) at > org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220) at > $Proxy0.addBlock(Unknown Source) at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) at > org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82) > at > org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59) > at $Proxy0.addBlock(Unknown Source) at > org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.locateFollowingBlock(DFSClient.java:2937) > at > org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream(DFSClient.java:2819) > at > org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2000(DFSClient.java:2102) > at > org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run(DFSClient.java:2288) > > 12/05/04 16:18:41 WARN hdfs.DFSClient: Error Recovery for block null > bad datanode[0] nodes == null 12/05/04 16:18:41 WARN hdfs.DFSClient: > Could not get block locations. Source file > "/user/hadoop/testfiles/testfiles/file1.txt" - Aborting... > copyFromLocal: java.io.IOException: File > /user/hadoop/testfiles/testfiles/file1.txt could only be replicated to > 0 nodes, instead of 1 12/05/04 16:18:41 ERROR hdfs.DFSClient: > Exception closing file /user/hadoop/testfiles/testfiles/file1.txt : > org.apache.hadoop.ipc.RemoteException: java.io.IOException: File > /user/hadoop/testfiles/testfiles/file1.txt could only be replicated to > 0 nodes, instead of 1 at > org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:1271) > at > org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock(NameNode.java:422) > at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source) at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) at > org.apache.hadoop.ipc.RPC$Server.call(RPC.java:508) at > org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:959) at > org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:955) at > java.security.AccessController.doPrivileged(Native Method) at > javax.security.auth.Subject.doAs(Subject.java:396) at > org.apache.hadoop.ipc.Server$Handler.run(Server.java:953) > > org.apache.hadoop.ipc.RemoteException: java.io.IOException: File > /user/hadoop/testfiles/testfiles/file1.txt could only be replicated to > 0 nodes, instead of 1 at > org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:1271) > at > org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock(NameNode.java:422) > at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source) at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) at > org.apache.hadoop.ipc.RPC$Server.call(RPC.java:508) at > org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:959) at > org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:955) at > java.security.AccessController.doPrivileged(Native Method) at > javax.security.auth.Subject.doAs(Subject.java:396) at > org.apache.hadoop.ipc.Server$Handler.run(Server.java:953) > > at org.apache.hadoop.ipc.Client.call(Client.java:740) at > org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220) at > $Proxy0.addBlock(Unknown Source) at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) at > org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82) > at > org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59) > at $Proxy0.addBlock(Unknown Source) at > org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.locateFollowingBlock(DFSClient.java:2937) > at > org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream(DFSClient.java:2819) > at > org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2000(DFSClient.java:2102) > at > org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run(DFSClient.java:2288)
当我执行时:
bin/stop-all.sh
它表示datanode尚未启动,因此无法停止。但是, jps 的输出表示存在datanode。
我尝试格式化namenode ,更改所有者权限,但它似乎无效。希望我没有错过任何其他相关信息。
提前致谢。
答案 0 :(得分:26)
对我有用的解决方案是逐个运行namenode和datanode,而不是使用bin/start-all.sh
一起运行。使用这种方法会发生的情况是,如果您在网络上设置数据节点时出现问题,则错误清晰可见,并且stackoverflow上的许多帖子都表明namenode需要一些时间来启动,因此,应该给它一些时间在启动datanode之前启动。此外,在这种情况下,我遇到了namenode和datanode的不同ID的问题,我必须更改datanode的id与namenode具有相同的id。
一步一步的程序将是:
bin/hadoop namenode
。检查错误(如果有)。bin/hadoop datanode
。检查错误(如果有)。答案 1 :(得分:7)
查看您的namenode(可能是http://localhost:50070),看看它有多少数据节点。
如果为0,则表示您的datanode未运行或未配置为连接到namenode。
如果为1,请检查DFS中有多少可用空间。可能是数据节点没有可以写入数据的任何地方(数据目录不存在,或者没有写入权限)。
答案 2 :(得分:4)
虽然已经解决了,但我正在为未来的读者添加这些内容。 Cody建议检查namenode和datanode的开头很有用,进一步的调查让我删除了hadoop-store / dfs目录。这样做可以解决这个错误。
答案 3 :(得分:2)
我有同样的问题,我看了一下datanode日志,并且有一个警告说dfs.data.dir有不正确的权限......所以我只是改变了它们,一切正常,这有点奇怪
具体来说,我的“dfs.data.dir”设置为“/ home / hadoop / hd_tmp”,我得到的错误是:
...
...
WARN org.apache.hadoop.hdfs.server.datanode.DataNode: Invalid directory in dfs.data.dir: Incorrect permission for /home/hadoop/hd_tmp/dfs/data, expected: rwxr-xr-x, while actual: rwxrwxr-x
ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: All directories in dfs.data.dir are invalid.
...
...
所以我只是执行了这些命令:
然后一切正常。
答案 4 :(得分:1)
就我而言,我错误地为dfs.name.dir
和dfs.data.dir
设置了一个目的地。正确的格式是
<property>
<name>dfs.name.dir</name>
<value>/path/to/name</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>/path/to/data</value>
</property>
答案 5 :(得分:1)
我删除了hdfs-site.xml中的额外属性,然后这个问题就消失了。 Hadoop需要改进他们的错误消息。我尝试了上述每个解决方案,但都没有。
答案 6 :(得分:0)
我遇到了同样的问题。当我查看 localhost:50070 时,在群集摘要下,所有属性都显示为0,但&#34; DFS已使用%100&#34;。通常,出现这种情况是因为HADOOP_INSTALL / conf和hosts文件下的三个 * - site.xml 文件中存在一些错误。
在我的情况下,原因无法解析主机名。我只是通过添加&#34; IP_Address主机名&#34;解决了这个问题。到 / etc / hosts 。
答案 7 :(得分:0)
在我的情况下,我不得不删除:
/tmp/hadoop-<user-name>
文件夹和格式,然后开始使用sbin/start-dfs.sh
sbin/start-yarn.sh