设为首页 收藏本站
查看: 1261|回复: 0

Hadoop配置:file could only be replicated to 0 nodes, instead of 1问题解决方法

[复制链接]

尚未签到

发表于 2015-11-11 15:04:33 | 显示全部楼层 |阅读模式
  今天执行bin/hadoop fs -copyFromLocal /Users/hadoop/Weibo/input/FavoriteFile.txt /user/hadoop/FavoriteFile.txt时候碰到了以下问题:
  file “*********”could only be replicated to 0 nodes, instead of 1

  然后check了一下dfshealth,发现是datanode挂掉了。
   DSC0000.png

  然后google了下官方给的建议,发现没有提供好的方案。
  http://wiki.apache.org/hadoop/CouldOnlyBeReplicatedTo

  
A common message people see is "could only be replicated to 0 nodes, instead of ...".
What does this mean? It means that the BlockReplication mechanism of HDFS could not make any copies of a file it wanted to create. This can be caused by

  • No DataNode instancesbeing up and running. Action: look at the servers, see if the processes are running.
  • The DataNode instancescannot talk to the server, through networking or Hadoop configuration problems. Action: look at the logs of one of the DataNodes.
  • Your DataNode instanceshave no hard disk space in their configured data directories. Action: look at the dfs.data.dir list in the node configurations, verify that at least one of the directories exists, and is writeable by the user running the Hadoop processes. Then look at thelogs.
  • Your DataNode instanceshave run out of space. Look at the disk capacity via the Namenode web pages. Delete old files. Compress under-used files. Buy more disks for existing servers (if there is room), upgrade the existing servers to bigger drives, or add some more servers.
  • The reserved space for a DN (as set in dfs.datanode.du.reserved is greater than the remaining free space, so the DN thinks it has no free space
  • You may also get this message due to permissions, eg if JT can not create jobtracker.info on startup.
This is not a problem in Hadoop, it is a problem in your cluster that you are going to have to fix on your own. Sorry.

  追究源码,NameNode身边的 ReplicationTargetChooser#isGoodTarget方法给出了说明:

Java代码   DSC0001.png

  • // check the communication traffic of the target machine  
  •     if (considerLoad) {  
  •       double avgLoad = 0;  
  •       int size = clusterMap.getNumOfLeaves();  
  •       if (size != 0) {  
  •         avgLoad = (double)fs.getTotalLoad()/size;  
  •       }  
  •       if (node.getXceiverCount() > (2.0 * avgLoad)) {  
  •         logr.debug("Node "+NodeBase.getPath(node)+  
  •                   " is not chosen because the node is too busy");  
  •         return false;  
  •       }  
  • }  

  isGoodTarget方法对预选的数据节点做出了终审判决,然而除了磁盘空间可利用外,另外需稳定在一定的压力之下,这里的标准是Datanode中XceiverServer所接受的连接数,我们在使用Hadoop时,这个值很容易被忽略,因为这个值不方便被统计到。上段代码说明当前节点的连接数,不得大于集群所有节点平均连接数的两倍。为了使我的系统尽量独力,我在dfshealth.jsp页面把每台节点的连接数打印了出来,结果发现正好符合上述代码的判断。


DSC0002.jpg


比如ReplicationTargetChooser选择了node13,那么即使node13有大片的空间可写,最终也会被上述代码认为是一个不符合条件的节点。

Java代码  

  • 157 > ((27 + 45 + 44 + 54 + 35 + 50 + 104 + 55 + 73 + 69 + 157 + 146)/12 * 2)  

这样的异常,一般解决办法是添加节点,或是在节点允许的情况下,对这段算法进行上调。

  
  后来手动将/hadoop/tmp/下面所有文件都删除(不需要删除文件夹),并重启了hadoop,通过jps发现namenode又起来了。
  
         版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-138004-1-1.html 上篇帖子: Hadoop Error Log 下篇帖子: Redhat 6.4-x64 编译 Hadoop-2.7.1并分布式安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表