hadoop启用防火墙的体验

来源:互联网 发布:淘宝刷单违规订单清洗 编辑:程序博客网 时间:2024/06/03 19:47
整体策略:集群内部开放所有端口,集群外部单独开放。
service iptables start
---启用INPUT/FORWARD链的防火墙检验
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
---允许集群局域网内机器IP(192.168.130.1-192.168.130.254) 访问
iptables -A INPUT -p tcp -s 192.168.130.0/24 -j ACCEPT
---开放127.0.0.1(允许本机访问本机)
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

---删除( iptables -D INPUT 2 )不必要规则,仅保留以下规则(通过执行 service iptables save 保留, iptables -L -n --line  查看)
Chain INPUT (policy DROP)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
2    ACCEPT     all  --  192.168.130.0/24     0.0.0.0/0           
3    ACCEPT     all  --  127.0.0.1            127.0.0.1           

Chain FORWARD (policy DROP)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  127.0.0.1            127.0.0.1   

---设置开机自启动
chkconfig iptables on

---通过CM启动集群,服务正常启动

---通过一个sparkSQL验证,运行正常;通过hql验证也正常。



至此,hadoop集群内部启用防火墙的验证完毕

原创粉丝点击