fence设备安装与配置,fence与pacemaker集群

一.fence

FENCE设备是RHCS集群中必不可少的一个组成部分,通过FENCE设备可以避免因出现不可预知的情况而造成的“脑裂”现象
FENCE设备的出现,就是为了解决类似这些问题,Fence设备主要就是通过服务器或存储本身的硬件管理接口
或者外部电源管理设备,来对服务器或存储直接发出硬件管理指令,将服务器重启或关机,或者与网络断开连接

二.fence设备安装与配置

1.安装fence设备安装包

[root@foundation13 cluster]# yum install -y fence-virt-0.4.0-4.el8.x86_64
[root@foundation13 cluster]# yum install -y fence-virtd-0.4.0-4.el8.x86_64
fence-virtd-libvirt-0.4.0-4.el8.x86_64  fence-virtd-multicast-0.4.0-4.el8.x86_64

2.fence服务配置,生成key,启动服务

[root@foundation13 ~]# fence_virtd -c
[root@foundation13 ~]# mkdir /etc/cluster
[root@foundation13 ~]# dd if=/dev/urandom of=/etc/cluster/fence_xvm.key bs=128 count=1
[root@foundation13 ~]# systemctl restart fence_virtd.service
[root@foundation13 ~]# systemctl disable --now firewalld

3.创建fence,做映射

[root@server1 ~]# mkdir /etc/cluster
[root@server1 ~]#ssh server2 mkdir /etc/cluster
[root@foundation13 ~]# scp fence_xvm.key server1:/etc/cluster
[root@foundation13 ~]# scp fence_xvm.key server2:/etc/cluster
[root@server1 ~]# stonith_admin -a fence_xvm -M
[root@server1 ~]# pcs property set stonith-enabled=true
[root@server1 ~]# pcs stonith create vmfence fence_xvm pcmk_host_map="server1:vm1;server2:vm2" op monitor interval=60s

4.将fence添加到pacemaker集群中

(1)fence一般会运行在业务的对端

[root@server1 ~]# pcs status

fence设备安装与配置,fence与pacemaker集群_第1张图片

(2)关闭server1

[root@server1 ~]# pcs cluster stop server1

fence设备安装与配置,fence与pacemaker集群_第2张图片

(3)重新开启server1

[root@server1 ~]# pcs cluster start server1

fence设备安装与配置,fence与pacemaker集群_第3张图片

(4)内核崩溃,fence自启动

[root@server2 cluster]# pcs cluster enable --all
server1: Cluster Enabled
server2: Cluster Enabled
[root@server2 cluster]# echo c > /proc/sysrq-triggerpacket_write_wait: Connection to 172.25.13.2 port 22: Broken pipe
[kiosk@foundation13 Desktop]$ ssh [email protected]
[email protected]'s password: 
Last login: Sun Aug  9 16:10:20 2020
[root@server2 ~]# pcs status

fence设备安装与配置,fence与pacemaker集群_第4张图片

你可能感兴趣的:(fence设备安装与配置,fence与pacemaker集群)