ls: Call From hdoop2/192.168.18.87 to hdoop2:8020 failed on connection exception: java.net.ConnectException: 拒绝连接; For more details see

时间:2021-08-08 05:13:54

场景:  预发环境中,同事已经搭建了一套hadoop集群,由于版本与所需不符,所以需要替换版本

问题描述: 在配置文件都准确的情况下,启动hadoop,出现以下报错:

启动之前初始化:   初始化目录跟配置文件目录不一致

hdfs  namenode -format

ls: Call From hdoop2/192.168.18.87 to hdoop2:8020 failed on connection exception: java.net.ConnectException: 拒绝连接; For more  details see

[root@hdoop2 hadoop-2.8.5]# hadoop dfs -ls /
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

ls: Call From hdoop2/192.168.18.87 to hdoop2:8020 failed on connection exception: java.net.ConnectException: 拒绝连接; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused

[root@hdoop2 hadoop-2.8.5]# jps      #namenode没启动
88467 SecondaryNameNode
88821 NodeManager
88692 ResourceManager
88254 DataNode
195389 AlertPublisher

排查:

[root@hdoop2 hadoop-2.8.5]# which hadoop
/usr/bin/hadoop

[root@hdoop2 hadoop-2.8.5]# which hdfs
/usr/bin/hdfs

[root@hdoop2 hadoop-2.8.5]# vim /etc/profile               #可以看到配置的hadoop环境没生效,原因是:之前在/usr/bin下配置了启动脚本,服务器优先回去读取/usr/bin下的启动程序

#hadoop
export HADOOP_HOME=/home/software/hadoop/hadoop-2.8.5
export PATH=$PATH:$HADOOP_HOME/bin

解决方法:

1.移除旧的环境变量

[root@hdoop2 hadoop-2.8.5]# mv /usr/bin/hadoop   /usr/bin/hadoop.old

[root@hdoop2 hadoop-2.8.5]# mv /usr/bin/hdfs /usr/bin/hdfs.old

[root@hdoop2 hadoop-2.8.5]# which hadoop     #可以看到配置的环境变量生效了
/home/software/hadoop/hadoop-2.8.5/bin/hadoop

2.重启hadoop

3.重新格式化:

[root@hdoop2 hadoop-2.8.5]# hadoop namenode -format

Re-format filesystem in Storage Directory /home/software/hadoop/hadoop-2.8.5/data/name ? (Y or N)

结果:  问题解决

总结:如果遇到了百思不得其解的问题,而且确认自己的配置没问题,那么:检查一下环境配置是否有问题 ---------MD。搞了TM俩天终于找到原因了,记录一下