宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

双心跳线

心跳线就是两台服务器之间再搭一个内网进行通信,保障主线断了,两台服务器还能通过内网线路通信。双心条线就在内网内某一个节点出现问题而其他节点不知道的时候就会通过另一条心跳线发出警告并将该节点提掉。

现在搭建怎么创建2个心跳线,这里准备多台PC:[root@foundation0 ~] 为真机
[root@nodea ~]、[root@nodeb ~]、[root@nodec ~]为3个节点
首先我们安装一个集群pcs包。
[root@nodea ~]# yum -y install pcs ;systemctl stop firewalld.service ;systemctl disable firewalld.service ;systemctl restart pcsd ;systemctl enable pcsd ; echo redhat |passwd –stdin hacluster *****nodea、nodeb、nodec都需要这样装

将nodea、nodeb、nodec授权给pcs并指定在hacluster用户下
[root@nodea ~]# pcs cluster auth nodea.cluster0.example.com nodeb.cluster0.example.com nodec.cluster0.example.com
Username: hacluster
Password:
nodea.cluster0.example.com: Authorized
nodeb.cluster0.example.com: Authorized
nodec.cluster0.example.com: Authorized

在真实机输入下面网站访问集群
[root@foundation0 ~]# firefox https://nodea.cluster0.example.com:2224

 

双心跳线-冯金伟博客园

1.png

1、添加
2、集群名:cluster-1
3-5、将nodea、nodeb、noddec主机名加入其中

 

点击进入集群cluster-1

 

双心跳线-冯金伟博客园

2.png

 

用下面命令查看当前心跳线的个数及IP地址
[root@nodea corosync]# corosync-cfgtool -s
Printing ring status.
Local node ID 1
RING ID 0
id = 172.25.0.10
status = ring 0 active with no faults

进入到/etc/corosync/会发现当前有几个配置文件
[root@nodea ~]# cd /etc/corosync/
[root@nodea corosync]# ls
corosync.conf corosync.conf.example.udpu uidgid.d
corosync.conf.example corosync.xml.example

首先我们需要将corosync.conf.example内的内容当模版
[root@nodea corosync]# vim corosync.conf.example

 

双心跳线-冯金伟博客园

3.png

 

1、将多余的文字去掉留下当前黑色范围内的内容复制

[root@nodea corosync]# vim corosync.conf

 

双心跳线-冯金伟博客园

4.png

 

1、增加一个active模式
2、心跳模版指定的IP地址为172.25.0.0网段
3、心跳模版指定的IP地址为192.168.0.0网段
*****由于真机和节点内的网卡IP都属于这2个网段

上面的配置文件做完后
[root@nodea corosync]# pcs cluster stop –all
nodea.cluster0.example.com: Stopping Cluster (pacemaker)…
nodeb.cluster0.example.com: Stopping Cluster (pacemaker)…
nodec.cluster0.example.com: Stopping Cluster (pacemaker)…
nodeb.cluster0.example.com: Stopping Cluster (corosync)…
nodec.cluster0.example.com: Stopping Cluster (corosync)…
nodea.cluster0.example.com: Stopping Cluster (corosync)…
[root@nodea corosync]# pcs cluster sync
nodea.cluster0.example.com: Succeeded
nodeb.cluster0.example.com: Succeeded
nodec.cluster0.example.com: Succeeded
[root@nodea corosync]# pcs cluster start –all
nodeb.cluster0.example.com: Starting Cluster…
nodec.cluster0.example.com: Starting Cluster…
nodea.cluster0.example.com: Starting Cluster…

先关掉集群使集群同步,后开启集群就可以看到有2个心跳线了
[root@nodea corosync]# corosync-cfgtool -s
Printing ring status.
Local node ID 1
RING ID 0
id = 172.25.0.10
status = ring 0 active with no faults
RING ID 1
id = 192.168.0.10
status = ring 1 active with no faults