# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
然后关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
重启你的服务器,两台都需要做
然后我们看一下双机状态!
[iyunv@ha1 ~]# pcs status
Cluster name: wuhaocluster
Last updated: Mon Jan 5 15:05:20 2015
Last change: Mon Jan 5 14:25:46 2015 via cibadmin on ha1
Stack: corosync
Current DC: ha2 (2) - partition with quorum
Version: 1.1.10-29.el7-368c726
2 Nodes configured
2 Resources configured
Online: [ ha1 ha2 ]
Full list of resources:
ClusterIP (ocf::heartbeat:IPaddr2): Started ha2
注意红色的部分,你成功将虚拟IP添加进入了你的集群!
下面,我们还要添加http服务进入到你的集群,你需要先安装他,并且写一个首页文件
yum install httpd
[iyunv@ha1 ~]# pcs status
Cluster name: wuhaocluster
Last updated: Mon Jan 5 15:13:21 2015
Last change: Mon Jan 5 14:25:46 2015 via cibadmin on ha1
Stack: corosync
Current DC: ha2 (2) - partition with quorum
Version: 1.1.10-29.el7-368c726
2 Nodes configured
2 Resources configured
Online: [ ha1 ha2 ]
Full list of resources:
ClusterIP (ocf::heartbeat:IPaddr2): Started ha2
Web (ocf::heartbeat:apache): Started ha1
注意红色的部分,到这里,恭喜你的HA已经配置好了,剩下的只是一些调整了,有没有注意到你的两个服务分别跑在两台机器上面?其实这是RHEL7双机比较好的地方,他认为应该利用每个节点的硬件资源,所以会智能的把服务跑在各个节点,但是对于我们这个http架构来说,入股你的虚拟IP和你的APACHE都不在一台机器上面,客户如何访问你的页面?所以我们需要修改
pcs constraintcolocation add Web ClusterIP INFINITY
上面的命令就是强制的把web和CLusterIP两个服务绑在一台机器上面,另外我们还需要确保ip服务一定是在http服务之前运行起来的,你想想看,没有IP,你httpd起来有什么意义?如果是一些特殊场景,比如数据库,你的数据在存储上面,如果存储不是在数据库启动脚本之前就被挂载起来,那ORACLE启动脚本怎么可能执行成功?
[iyunv@ha1 ~]# pcs constraint order ClusterIP then Web
好,我们再看下双机状态
[iyunv@ha1 ~]# pcs status
Cluster name: wuhaocluster
Last updated: Mon Jan 5 15:13:21 2015
Last change: Mon Jan 5 14:25:46 2015 via cibadmin on ha1
Stack: corosync
Current DC: ha2 (2) - partition with quorum
Version: 1.1.10-29.el7-368c726
2 Nodes configured
2 Resources configured
Online: [ ha1 ha2 ]
Full list of resources:
ClusterIP (ocf::heartbeat:IPaddr2): Started ha2
Web (ocf::heartbeat:apache): Started ha2