java.net.ConnectException:在Hadoop中使用shell命令时拒绝连接

java.net.ConnectException:在Hadoop中使用shell命令时拒绝连接,java,linux,ubuntu,hadoop,hdfs,Java,Linux,Ubuntu,Hadoop,Hdfs,我已经安装了7个运行Ubuntu服务器14.04 LTS的VM实例。instance-1(主机名)运行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

我已经安装了7个运行Ubuntu服务器14.04 LTS的VM实例。instance-1(主机名)运行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
这是我在实例2上的jps输出

root@instance-2:~# jps
2267 NodeManager
5012 Jps
2274 DataNode
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
这是我在实例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
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
我试图从实例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:~# 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
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:~# jps
2267 NodeManager
5012 Jps
2274 DataNode
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
实例1上的netstat命令未显示在端口8020上运行的任何内容

root@instance-1:~# netstat -tulpn | grep 8020
root@instance-1:~# netstat -tulpn | grep 8020
root@instance-1:~# netstat -tulpn | grep 8020
希望这些信息能帮助你调查这个问题。
提前感谢。

尝试禁用Ubuntu虚拟机的防火墙。这个链接将有助于您的阅读。否则您也可以添加

基于云提供商,您可以打开虚拟机的端口。如果您正在使用,请打开安全组中VM所需的端口号。。 如果您使用的是添加所需的端点


添加异常后,从namenode重新启动hadoop服务。希望一切顺利

在您尝试连接的IP:端口上没有任何内容正在侦听。您试图通过此连接创建目录的事实与此无关。telnet和netstat输出证实了这一点。在my core-site.xml中,fs.defaultfs属性设置为hdfs://instance-1:8020.So 您已经配置了它,但它仍然没有运行。