HDFS追加数据报错解决办法

【HDFS追加数据报错解决办法】主要的两个错误 , 今天晚上一直轮着报:
第一个2022-10-25 21:37:11,901 WARN hdfs.DataStreamer: DataStreamer Exceptionjava.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.88.151:9866,DS-4b3969ed-e679-4990-8d2e-374f24c1955d,DISK]], original=[DatanodeInfoWithStorage[192.168.88.151:9866,DS-4b3969ed-e679-4990-8d2e-374f24c1955d,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.at org.apache.hadoop.hdfs.DataStreamer.findNewDatanode(DataStreamer.java:1304)at org.apache.hadoop.hdfs.DataStreamer.addDatanode2ExistingPipeline(DataStreamer.java:1372)at org.apache.hadoop.hdfs.DataStreamer.handleDatanodeReplacement(DataStreamer.java:1598)at org.apache.hadoop.hdfs.DataStreamer.setupPipelineInternal(DataStreamer.java:1499)at org.apache.hadoop.hdfs.DataStreamer.setupPipelineForAppendOrRecovery(DataStreamer.java:1481)at org.apache.hadoop.hdfs.DataStreamer.run(DataStreamer.java:719)appendToFile: 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.88.151:9866,DS-4b3969ed-e679-4990-8d2e-374f24c1955d,DISK]], original=[DatanodeInfoWithStorage[192.168.88.151:9866,DS-4b3969ed-e679-4990-8d2e-374f24c1955d,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出问题,就一直无法写入成功 。
当时我也是在进行操作时只打开了集群中的一台机器,然后datanode应该是集群中的数量,但是我只有一个,所以报错了 。然后我让三台机器都启动了Hadoop , 然后就可以了 。
网上普遍的方法是修改hdfs-core.xml文件,如下:
<property><name>dfs.support.append</name><value>true</value></property><property><name>dfs.client.block.write.replace-datanode-on-failure.policy</name><value>NEVER</value></property><property><name>dfs.client.block.write.replace-datanode-on-failure.enable</name><value>true</value></property>网上对节点响应是这么解释的,我觉得对于二、三节点这个可以留意一下:dfs.client.block.write.replace-datanode-on-failure.policy , default在3个或以上备份的时候,是会尝试更换结点尝试写入datanode 。而在两个备份的时候,不更换datanode,直接开始写 。对于3个datanode的集群,只要一个节点没响应写入就会出问题,所以可以关掉 。
第二个appendToFile: Failed to APPEND_FILE /2.txt for DFSClient_NONMAPREDUCE_505101511_1 on 192.168.88.151 because this file lease is currently owned by DFSClient_NONMAPREDUCE_-474039103_1 on 192.168.88.151appendToFile: Failed to APPEND_FILE /2.txt for DFSClient_NONMAPREDUCE_814684116_1 on 192.168.88.151 because lease recovery is in progress. Try again later.第二个就是这两句话来回捣,但是我看because后都是lease,我感觉应该是一个问题,这个应该就是网上所说的节点响应吧,我看第一句后面提到了owned by DFSClient , 估计是我只开了一个机器的问题,因为后面的IP就是第一台机器,如果你们全开了,拿应该就是节点响应问题,这就回到了上面,就去老老实实修改文件吧 。

    推荐阅读