hadoop append 追加文件错误

来源:互联网 发布:windows snmp命令 编辑:程序博客网 时间:2024/05/20 14:16
  1. java.io.IOException: Failed to replace a bad datanode on the existing pipeline due to no more good datanodes being available to try. (Nodes: current=[DatanodeInfoWithStorage[192.168.168.200:50010,DS-039c3e9e-2b2a-44e8-9f3e-8584b6c3f2c3,DISK]], original=[DatanodeInfoWithStorage[192.168.168.200:50010,DS-039c3e9e-2b2a-44e8-9f3e-8584b6c3f2c3,DISK]]). The current failed datanode replacement policy is DEFAULT, and a client may configure this via 'dfs.client.block.write.replace-datanode-on-failure.policy' in its configuration.
原因:无法写入;我的环境中有3个datanode,备份数量设置的是3。在写操作时,它会在pipeline中写3个机器。默认replace-datanode-on-failure.policy是DEFAULT,如果系统中的datanode大于等于3,它会找另外一个datanode来拷贝。目前机器只有3台,因此只要一台datanode出问题,就一直无法写入成功。

解决办法:修改hdfs-site.xml文件,添加或者修改如下两项: 
  1. <property>
  2.   <name>dfs.client.block.write.replace-datanode-on-failure.enable</name>
  3.   <value>true</value>
  4. </property>
  5. <property>
  6.   <name>dfs.client.block.write.replace-datanode-on-failure.policy</name>
  7.   <value>NEVER</value>
  8. </property>
对于dfs.client.block.write.replace-datanode-on-failure.enable,客户端在写失败的时候,是否使用更换策略,默认是true没有问题。
对于,dfs.client.block.write.replace-datanode-on-failure.policy,default在3个或以上备份的时候,是会尝试更换结点尝试写入datanode。而在两个备份的时候,不更换datanode,直接开始写。对于3个datanode的集群,只要一个节点没响应写入就会出问题,所以可以关掉。/ 
或者在客户端的代码里面加入:   
  1. conf = new Configuration();
  2. conf.set("dfs.client.block.write.replace-datanode-on-failure.policy","NEVER"); 
  3. conf.set("dfs.client.block.write.replace-datanode-on-failure.enable","true"); 
原创粉丝点击