Hadoop: datanode连接namenode 9000端口报错 NoRouteToHostException: No route to host

hadoop集群搭建好后,在datanode节点上执行hadoop fs命令,报下面的错

[hadoop@hdp02 ~]$ hadoop fs -ls /
ls: No Route to Host from  hdp02/192.168.60.102 to hdp01:9000 failed on socket timeout exception: java.net.NoRouteToHostException: No route to host; For more details see:  http://wiki.apache.org/hadoop/NoRouteToHost

百度了下,各种博客说要关闭防火墙,但是如果真的关闭防火墙,就相当于对任何外界机器的访问,都没了安全可言。这种方式是不可取的。想到以前配过iptable过滤,这次也应该是这个原因。集群各节点同属于一个内网,我配置这个内网可以互相任意访问一些端口不就好了?

安装iptable iptable-service

#先检查是否安装了iptables
service iptables status
#安装iptables
yum install -y iptables
#升级iptables
yum update iptables 
#安装iptables-services
yum install iptables-services

禁用/停止自带的firewalld服务

#停止firewalld服务
systemctl stop firewalld
#禁用firewalld服务
systemctl mask firewalld

配置iptables对内网所在网段开放所有端口 (需要root用户权限)

vim /etc/sysconfig/iptables

添加一行规则

-A INPUT -p all -s 192.168.60.0/24 -j ACCEPT

将该iptables文件发给内网其他节点

目前我的内网其他节点为hdp02,hdp03

cd /etc/sysconfig

# scp 拷贝文件到其他节点(需要ssh协议)

scp -r iptables hdp02:$PWD/  

scp -r iptables hdp02:$PWD/

对各节点执行service iptables save

用telnet测试

内网集群节点hdp01,hdp02,hdp03分别安装telnet

yum install -y telnet

然后在hdp02,hdp03 执行telnet hdp01 9000

[root@hdp02 ~]# telnet hdp01 9000
Trying 192.168.60.101...
Connected to hdp01.
Escape character is '^]'.

连接成功!

退出telnet : 先输入 Ctrl+] ,然后输入quit 命令,完成退出

执行hdfs 相关命令

[hadoop@hdp02 ~]$ echo "hadoop file" > hadoop01.txt
[hadoop@hdp02 ~]$ hadoop fs -mkdir /hadoop
[hadoop@hdp02 ~]$ hadoop fs -put hadoop01.txt /hadoop/
[hadoop@hdp02 ~]$ hadoop fs -ls -h /hadoop
Found 1 items
-rw-r--r--   3 hadoop supergroup         12 2020-04-05 21:49 /hadoop/hadoop01.txt

毫无疑问,执行成功!

猜你喜欢

转载自blog.csdn.net/dinghua_xuexi/article/details/105333923