赞
踩
一、背景描述:此时有node1,node2,node3虚拟机
HDFS中存在/itcast/1.txt文件
linux_node2中/test/下存在2.txt和3.txt
现在上传本地2.txt,3.txt文件到HDFS中追加到1.txt文件的末尾
二、显示报错如下:
1.第一报错
- [root@node2 ~]# hadoop fs -appendToFile 2.txt 3.txt /itcast/1.txt
- 2023-06-06 11:22:37,011 WARN hdfs.DataStreamer: DataStreamer Exception
- 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.88.152:9866,DS-c220bd52-1e8d-406a-ac61-8c310e39364f,DISK], DatanodeInfoWithStorage[192.168.88.151:9866,DS-115b8ce0-0944-44f6-8638-e123a08e806f,DISK]], original=[DatanodeInfoWithStorage[192.168.88.151:9866,DS-115b8ce0-0944-44f6-8638-e123a08e806f,DISK], DatanodeInfoWithStorage[192.168.88.152:9866,DS-c220bd52-1e8d-406a-ac61-8c310e39364f,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: /root/2.txt
原因:node3的HDFS的从节点失联
解决:可以查看我其他笔记查看这个问题解决思路
2.第二个报错:
- [root@node2 ~]# hadoop fs -appendToFile 2.txt 3.txt /itcast/1.txt
- appendToFile: Failed to APPEND_FILE /itcast/1.txt for DFSClient_NONMAPREDUCE_-1199279342_1 on 192.168.88.152 because lease recovery is in progress. Try again later.
原因:文件的权限只有读的权限
解决:修改HDFS中的1.txt的文件权限
[root@node2 ~]# hadoop fs -chmod 777 /itcast/1.txt
3.第三个报错:
- [root@node2 ~]# hadoop fs -appendToFile 2.txt 3.txt /itcast/1.txt
- appendToFile: /root/2.txt
原因:发现上传拼接的路径不对,上述命令的路径不是/目录下
解决:查看文件存在的路径
修改文件上传的路径如下
- [root@node2 ~]# ll
- total 24
- -rw-r--r-- 1 root root 0 Jun 6 08:24 1.txt
- -rw-------. 1 root root 1365 Jun 4 11:52 anaconda-ks.cfg
- drwxr-xr-x 2 root root 84 Jun 6 08:36 test
- -rw-r--r-- 1 root root 19263 Jun 4 22:00 zookeeper.out
- [root@node2 ~]# cd test
- [root@node2 test]# ll
- total 16
- -rw-r--r-- 1 root root 2 Jun 6 08:25 1.txt
- -rw-r--r-- 1 root root 2 Jun 6 08:26 2.txt
- -rw-r--r-- 1 root root 2 Jun 6 08:26 3.txt
- -rw-r--r-- 1 root root 6 Jun 6 08:36 merge.txt
- [root@node2 test]# hadoop fs -appendToFile 2.txt 3.txt /itcast/1.txt
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。