用CentOS7.0做集群,发现了许多问题,主要总结如下:
1.配置文件的配置参数有错误。
2.操作系统的环境没有设置好。
3.文件的权限没有分配好。
常见的错误如下:
1.环境问题
centos7关闭防火墙
当时一直认为关闭防火墙的命令是:systemctl iptables stop
直接命令:service firewalld stop
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙
firewall:
systemctl start firewalld.service#启动firewall
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动
可以替换为iptables
firewall:
systemctl start iptables.service
总结:
CentOS7用firewall命令“替代”了iptables。在这里我们需要区分“iptables服务”和“iptables命令”。虽然firewalld是替代提供的防火墙管理iptables服务,但是它仍然使用iptables对内核命令动态通信包过滤。所以它只是iptables服务代替,而不是iptables命令。
1. Disable Firewalld Service.
[root@rhel-centos7-linux ~]# systemctl mask firewalld
2. Stop Firewalld Service.
[root@rhel-centos7-linux ~]# systemctl stop firewalld
3. Install iptables service related packages.
[root@rhel-centos7-linux ~]# yum -y install iptables-services
4. Make sure service starts at boot:
[root@rhel-centos7-linux ~]# systemctl enable iptables
# If you do not want ip6tables, You can skip following command.
[root@rhel-centos7-linux ~]# systemctl enable ip6tables
5. Now, Finally Let’s start the iptables services.
[root@rhel-centos7-linux ~]# systemctl start iptables
# If you do not want ip6tables, You can skip following command.
[root@rhel-centos7-linux ~]# systemctl start ip6tables
Firewalld Service is now disabled and stop, You can use iptables.
检查防火墙状态
firewall-cmd --stat
临时开放ftp服务
firewall-cmd --add-service=ftp
永久开放ftp服务
firewall-cmd --add-service=ftp --permanent
关闭ftp服务
firewall-cmd --remove-service=ftp --permanent
配置防火墙在public区域永久开放http服务
firewall-cmd --permanent --zone=public --add-service=http
加入指定开放端口
firewall-cmd --add-port=1324/tcp
为了让之前的设定生效当然要重启服务咯
systemctl restart firewalld
或者使用下面的命令免去重启服务(防火墙策略配置后重新载入)
firewall-cmd --complete-reload
firewall-cmd --reload (这两句功能相同)
检查ftp服务的21端口是否开放
iptables -L -n | grep 21
ACCEPT tcp -- 0.0.0.0/0