hadoop使用常见问题总结!
阅读原文时间:2023年07月08日阅读:2

1,执行 hdfs dfs -copyFromLocal 命令报错!

19/01/02 11:01:32 INFO hdfs.DFSClient: Exception in createBlockOutputStream
java.net.ConnectException: 拒绝连接
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)
at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:531)
at org.apache.hadoop.hdfs.DFSOutputStream.createSocketForPipeline(DFSOutputStream.java:1702)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1432)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1385)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:554)
19/01/02 11:01:32 INFO hdfs.DFSClient: Abandoning BP-719105237-127.0.0.1-1525595716995:blk_1073741854_1030
19/01/02 11:01:32 INFO hdfs.DFSClient: Excluding datanode DatanodeInfoWithStorage[127.0.0.1:50010,DS-ababb49a-42c6-452b-9992-e0dc201a08b5,DISK]
19/01/02 11:01:32 WARN hdfs.DFSClient: DataStreamer Exception
org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /tempdata/README.md._COPYING_ could only be replicated to 0 nodes instead of minReplication (=1). There are 1 datanode(s) running and 1 node(s) are excluded in this operation.
at org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.chooseTarget4NewBlock(BlockManager.java:1628)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getNewBlockTargets(FSNamesystem.java:3121)

解决办法: 关闭防火墙:

systemctl -stop firewalld.service

永久关闭防火墙:

systemctl disable firewalld.service

也可以永久关闭selinux:使用  vim /etc/selinux/config 命令修改/etc/selinux/config 文件 
设置“SELINUX=disabled” ,再次执行上传文件操作成功。

2,出现 Unable to load native-hadoop library for your platform的警告信息处理方式!

WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform… using builti

在/HADOOP_HOME/etc/hadoop/(也就是hadoop的配置文件目录下的)中的hadoop_env.sh头部添加了如下信息:

export HADOOP_COMMON_LIB_NATIVE_DIR="/usr/local/hadoop/lib/native/"
export HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=/usr/local/hadoop/lib/native/"

  其中的 /usr/local/hadoop是我的haddoop安装目录,请根据自己的安装目录设置即可!