【问题标题】:java.net.ConnectException: Connection refused in Hadoop while using shell commandsjava.net.ConnectException:使用 shell 命令时 Hadoop 中的连接被拒绝
【发布时间】:2015-05-25 08:54:17
【问题描述】:

我已经安装了 7 个运行 Ubuntu 服务器 14.04 LTS 的 VM 实例。 instance-1(hostname) 运行 namenode 和其他几个服务,而所有其他实例运行 datanode 服务。我想在一个 datanode 的 hdfs 根目录上创建一个目录,但我收到了这个错误

root@instance-2:~# hdfs dfs -mkdir hdfs://localhost/user/
mkdir: Call From instance-2/10.240.17.255 to localhost:8020 failed on
connection exception: java.net.ConnectException: Connection refused; For 
more details see:  http://wiki.apache.org/hadoop/ConnectionRefused
root@instance-2:~# hdfs dfs -mkdir hdfs://instance-2/user/
mkdir: Call From instance-2/10.240.17.255 to instance-2:8020 failed on
connection exception: java.net.ConnectException: Connection refused; For 
more details see:  http://wiki.apache.org/hadoop/ConnectionRefused

这是我在 instance-2 上的 jps 输出

root@instance-2:~# jps
2267 NodeManager
5012 Jps
2274 DataNode

这是我在 instance-1 上的 jps 输出

root@instance-1:~# jps
9043 Jps
1490 Main
3011 RunJar
3227 ResourceManager
4736 HeadlampServer
2409 SecondaryNameNode
3095 JobHistoryServer
2411 QuorumPeerMain
2734 AlertPublisher
2423 RunJar
2562 Bootstrap
5059 Main
2430 Bootstrap
5174 EventCatcherService
5060 Main
2487 NameNode

我尝试从 instance-1 创建目录,但仍然遇到同样的错误

root@instance-1:~# hdfs dfs -mkdir hdfs://instance-2/user/
mkdir: Call From instance-1/10.240.71.132 to instance-2:8020 failed on 
connection exception: java.net.ConnectException: Connection refused; For 
more details see:  http://wiki.apache.org/hadoop/ConnectionRefused

这是我的实例 1 的主机文件

root@instance-1:~# cat /etc/hosts
127.0.0.1 localhost
10.240.71.132 instance-1
10.240.17.255 instance-2
10.240.50.197 instance-3
10.240.61.121 instance-4
10.240.98.215 instance-5
10.240.72.7 instance-6
10.240.216.72 instance-7
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
169.254.169.254 metadata.google.internal metadata

这是我的实例 2 的主机文件

root@instance-2:~# cat /etc/hosts
127.0.0.1 localhost
10.240.71.132 instance-1
10.240.17.255 instance-2
10.240.50.197 instance-3
10.240.61.121 instance-4
10.240.98.215 instance-5
10.240.72.7 instance-6
10.240.216.72 instance-7
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
169.254.169.254 metadata.google.internal metadata

这里是telnet命令输出

root@instance-2:~# telnet localhost 8020
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

root@instance-2:~# telnet instance-2 8020
Trying 10.240.17.255...
telnet: Unable to connect to remote host: Connection refused

instance-1 上的 netstat 命令显示端口 8020 上没有运行

root@instance-1:~# netstat -tulpn | grep 8020
root@instance-1:~# netstat -tulpn | grep 8020
root@instance-1:~# netstat -tulpn | grep 8020

希望此信息能帮助您调查问题。 提前致谢。

【问题讨论】:

  • 在您尝试连接的 IP:port 上没有任何东西在监听。您尝试通过此连接创建目录这一事实无关紧要。
  • telnet 和 netstat 输出证实了这一点。
  • 在我的 core-site.xml 中,fs.defaultfs 属性设置为 hdfs://instance-1:8020。
  • 所以你已经配置了它,但它仍然没有运行。

标签: java linux ubuntu hadoop hdfs


【解决方案1】:

尝试为您的 Ubuntu 虚拟机禁用防火墙。此链接将有助于disable the firewall。否则你也可以添加exception to the firewall

根据云提供商,您可以打开虚拟机的端口。如果您使用AMS EC2,请在安全组中为您的虚拟机打开所需的端口号。 如果您使用的是Microsoft Azure,请添加所需的端点。

添加异常后,从 namenode 重新启动您的 hadoop 服务。希望一切都会好起来。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-18
    • 2018-06-10
    • 1970-01-01
    • 2023-03-21
    • 2017-08-10
    相关资源
    最近更新 更多