使用两个节点:
在两台服务器上安装HA工具:
yum install pacemaker pcs
(它将包括安装corosync)
在两台服务器上:
passwd hacluster
为集群设置相同的密码。
在两台服务器上:
systemctl enable pcsd.service systemctl start pcsd.service
validation群集节点:
node1# pcs cluster auth 192.168.0.1 192.168.0.2
他们都成功通过authentication。
生成corosyncconfiguration:
node1# pcs cluster setup --name mycluster 192.168.0.1 192.168.0.2
启动群集:
node1# pcs cluster start --all
成功。
确认状态:
pcs status corosync Output Membership information ---------------------- Nodeid Votes Name 2 1 192.168.0.2 1 1 192.168.0.1 (local)
获取有关集群当前状态的更多信息:
pcs cluster status Output Cluster Status: ... Stack: corosync ... 2 nodes and 0 resources configured Online: [ node1 node2 ] PCSD Status: node1 (192.168.0.1): Online node2 (192.168.0.2): Online
在两台服务器上启用corosync和pacemaker服务:
systemctl enable corosync.service systemctl enable pacemaker.service
禁用STONITH
node1# pcs property set stonith-enabled=false
创build一个浮动IP并将其添加到pcs资源后,testing故障转移。
在node1上:
reboot
那就麻烦了 重启后,再次运行pcs cluster status ,显示:
Cluster Status: Stack: corosync Current DC: centos7lb1 (version 1.1.15-11.el7_3.5-e174ec8) - partition WITHOUT quorum Last updated: Sun Jul 23 23:47:53 2017 Last change: Fri Jul 21 05:56:32 2017 by hacluster via crmd on node1 1 node and 0 resources configured PCSD Status: node1 (192.168.0.1): Online *Unknown* (192.168.0.2): Online
在node1上运行pcs status :
Cluster name: mycluster WARNING: corosync and pacemaker node names do not match (IPs used in setup?) Stack: corosync Current DC: node1 (version 1.1.15-11.el7_3.5-e174ec8) - partition WITHOUT quorum Last updated: Sun Jul 23 23:58:22 2017 Last change: Fri Jul 21 05:56:32 2017 by hacluster via crmd on node1 1 node and 0 resources configured Online: [ node1 ] No resources Daemon Status: corosync: active/disabled pacemaker: active/disabled pcsd: active/enabled
在集群中找不到node2 。 同时检查node2上的状态,也只有一个节点( node2 )。 与node1相同,在集群中找不到另一个节点。
我试图删除起搏器,corosync和个人电脑,并再次重做。 但是做完之后
yum remove pacemaker pcs
然后validation它们:
pcs cluster auth node1 node2
显示他们Already authorized 。
那么这个时候怎么把这两个节点重新合并到集群呢? 我想清除它们,那怎么办?
原因是防火墙。
由于Corosync在端口5404和5405上使用UDP传输,因此我添加了:
iptables -I INPUT -m state --state NEW -p udp -m multiport --dports 5404,5405 -j ACCEPT iptables -I OUTPUT -m state --state NEW -p udp -m multiport --sports 5404,5405 -j ACCEPT service iptables save
并停止/启动所有群集:
pcs cluster stop --all pcs cluster start --all
还跑了:
service corosync restart
集群起作用。 所有的节点都可以看到,并全部在线。