我是hadoop的新手,我正试图在我的ubuntu机器上进行伪分布式模式设置,并且面临一个问题 hadoop put
命令。我的配置细节可以在这篇文章-->命令“hadoopnamenode-format”将做什么中找到
现在我尝试使用以下命令将一些文件添加到hdfs:
hadoop fs –mkdir /user/myuser
hadoop fs -lsr /
$ ./hadoop fs -lsr /
drwxr-xr-x - myuser supergroup 0 2014-11-26 16:04 /tmp
drwxr-xr-x - myuser supergroup 0 2014-11-26 16:04 /tmp/hadoop-myuser
drwxr-xr-x - myuser supergroup 0 2014-11-26 16:04 /tmp/hadoop-myuser/dfs
-rw-r--r-- 1 myuser supergroup 0 2014-11-26 16:04 /tmp/hadoop-myuser/dfs/name
drwxr-xr-x - myuser supergroup 0 2014-11-26 16:04 /tmp/hadoop-myuser/mapred
drwx------ - myuser supergroup 0 2014-11-26 16:12 /tmp/hadoop-myuser/mapred/system
drwxr-xr-x - myuser supergroup 0 2014-11-26 16:04 /user
drwxr-xr-x - myuser supergroup 0 2014-11-26 16:06 /user/myuser
现在我负责 put
命令,但得到如下异常:
$ ./hadoop fs -put example.txt .
14/11/26 16:06:19 WARN hdfs.DFSClient: DataStreamer Exception: org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /user/myuser/example.txt could only be replicated to 0 nodes, instead of 1
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:1920)
at org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock(NameNode.java:783)
at sun.reflect.GeneratedMethodAccessor5.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: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:396)
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.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: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)
14/11/26 16:06:19 WARN hdfs.DFSClient: Error Recovery for null bad datanode[0] nodes == null
14/11/26 16:06:19 WARN hdfs.DFSClient: Could not get block locations. Source file "/user/myuser/example.txt" - Aborting...
put: java.io.IOException: File /user/myuser/example.txt could only be replicated to 0 nodes, instead of 1
14/11/26 16:06:19 ERROR hdfs.DFSClient: Failed to close file /user/myuser/example.txt
org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /user/myuser/example.txt could only be replicated to 0 nodes, instead of 1
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:1920)
at org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock(NameNode.java:783)
at sun.reflect.GeneratedMethodAccessor5.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: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:396)
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.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: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)
有人能帮我解决这个问题吗?
问题解决方案:
根据提供的答案,我可以通过以下步骤解决问题:
1) 停止所有服务:
./stop-all.sh
2) 删除数据目录:
rm -rf /tmp/hadoop-myuser/dfs/data/
3) 启动服务:
./start-all.sh
4) 然后将文件放入hdfs:
./hadoop fs -put example.txt .
2条答案
按热度按时间czq61nw11#
您是否检查过“hdfs site.xml”中的“dfs.replication”至少有1个。我想你可以把0复制。
还要检查所有hadoop服务是否正在运行?
检查运行状态:运行
JPS
命令要单独启动服务:转到
...\hadoop\bin\
```start hadoop {datanode \ namenode}
start yarn {nodemanager \ resourcemanager}
rkkpypqq2#
这是由于数据节点问题造成的。启动datanode并立即执行操作