hadoop上传文件到hdfs出错
通过命令:
Hadoop fs -put /opt/program/userall20140828 hdfs://localhost:9000/tmp/tvbox/
上传文件到hdfs是出现错误
14/12/11 17:57:49 WARN hdfs.DFSClient: DataStreamer Exception: org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /tmp/tvbox/behavior_20141210.log 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) purpose at sun.reflect.GeneratedMethodAccessor9.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: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:415) 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 com.sun.proxy.$Proxy0.addBlock(Unknown Source) 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:82) at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59) at com.sun.proxy.$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) 14/12/11 17:57:49 WARN hdfs.DFSClient: Error Recovery for block null bad datanode[0] nodes == null 14/12/11 17:57:49 WARN hdfs.DFSClient: Could not get block locations. Source file "/tmp/tvbox/behavior_20141210.log" - Aborting... put: java.io.IOException: File /tmp/tvbox/behavior_20141210.log could only be replicated to 0 nodes, instead of 1 14/12/11 17:57:49 ERROR hdfs.DFSClient: Exception closing file /tmp/tvbox/behavior_20141210.log : org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /tmp/tvbox/behavior_20141210.log 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.GeneratedMethodAccessor9.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: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:415) at org.apache.hadoop.ipc.Server$Handler.run(Server.java:953) org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /tmp/tvbox/behavior_20141210.log 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.GeneratedMethodAccessor9.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: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:415) 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 com.sun.proxy.$Proxy0.addBlock(Unknown Source) 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:82) at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59) at com.sun.proxy.$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)
网上找了一圈,大概由以下原因造成:
1、 防火墙问题(排除)
查看iptables状态:
serviceiptables status
iptables开机自动启动:
开启: chkconfigiptables on
关闭: chkconfigiptables off
iptables关闭服务:
开启: service iptablesstart
关闭: service iptables stop
2、 添加节点的原因,也就是说需要先启动namenode,再启动datanode,然后启动jobtracker和tasktracker(排除)
1. 重新启动namenode
# hadoop-daemon.sh start namenode
starting namenode, logging to/usr/hadoop-0.21.0/bin/../logs/hadoop-root-namenode-www.keli.com.out
2. 重新启动datanode
# hadoop-daemon.sh start datanode
starting datanode, logging to/usr/hadoop-0.21.0/bin/../logs/hadoop-root-datanode-www.keli.com.out
start-all.sh中的启动顺序是对的。
3、 磁盘空间问题(命中!!!)
解决步骤:
1. 通过命令df –ah查看空间使用情况,
[root@localhost hadoop]# df -ah Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 15G 12M 100% / proc 0 0 0 - /proc sysfs 0 0 0 - /sys devpts 0 0 0 - /dev/pts tmpfs 937M 224K 937M 1% /dev/shm /dev/sda1 291M 37M 240M 14% /boot none 0 0 0 - /proc/sys/fs/binfmt_misc .host:/ 196G 209M 196G 1% /mnt/hgfs vmware-vmblock 0 0 0 - /var/run/vmblock-fuse gvfs-fuse-daemon 0 0 0 - /root/.gvfs
2. 备份清空hadoop/logs中的日志
再次查看空间使用情况,再次上传文件,ok,成功!
关于清空空间大小,清空logs后,还是使用了15G,应该还有其他地方可以继续清空,欢迎指教!
[root@localhost hadoop]# df -ah Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 15G 2.1G 88% / proc 0 0 0 - /proc sysfs 0 0 0 - /sys devpts 0 0 0 - /dev/pts tmpfs 937M 224K 937M 1% /dev/shm /dev/sda1 291M 37M 240M 14% /boot none 0 0 0 - /proc/sys/fs/binfmt_misc .host:/ 196G 209M 196G 1% /mnt/hgfs vmware-vmblock 0 0 0 - /var/run/vmblock-fuse gvfs-fuse-daemon 0 0 0 - /root/.gvfs
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。