fence应用

每个节点之间互相发送探测包进行判断节点的存活性。一般会有专门的线路进行探测,这条线路称为“心跳线”(上图直接使用eth0线路作为心跳线)。假设node1的心跳线出问题,则node2和node3会认为node1出问题,然后就会把资源调度在node2或者node3上运行,但node1会认为自己没问题不让node2或者node3抢占资源,此时就出现了脑裂(split brain)。
此时如果在整个环境里有一种设备直接把node1断电,则可以避免脑裂的发生,这种设备叫做fence或者stonith(Shoot The Other Node In The Head爆头哥)。
在物理机里virsh是通过串口线管理guestos的,比如virsh destroy nodeX,这里我们把物理机当成fence设备

注意:在真实主机下载fence来使用(作为服务器接受server发送的数据来判断server是否存活)

安装fence:yum install -y fence-virt.x86_64

查询:rpm -qa | grep fence

在这里插入图片描述

创建钥匙:

fence_virt -c 
#命令执行后 <Enter>到网卡时
Multicast IP Port [1229]: 

Setting a preferred interface causes fence_virtd to listen only
on that interface.  Normally, it listens on all interfaces.
In environments where the virtual machines are using the host
machine as a gateway, this *must* be set (typically to virbr0).
Set to 'none' for no interface.

Interface [br0]: 
#到这不时需要注意自己和虚拟机之间使用的是什么网卡  如果就是br0 直接<Enter>
The key file is the shared key information which is used to
authenticate fencing requests.  The contents of this file must
be distributed to each physical host and virtual machine within
a cluster.
#前后的步骤都只需要<Enter>

创建文件夹:mkdir /etc/cluster

cd /etc/cluster
dd if=/dev/urandom of=fence_xvm.key bs=128 count=1

在这里插入图片描述
将钥匙发给server2,server3 在两台虚拟机上面创建 /etc /mkdir
发送 scp /etc/cluster/fence_xvm.key server2:/etc/cluster/ scp /etc/cluster/fence_xvm.key server3:/etc/cluster/
在server2,server3 在两台虚拟机上面安装yum install -y fence-virt.x86_64

全部重启服务 systemctl disable --now fence_virtd.service

查看端口:netstat -anlpu | grep 1229 udp 0 0 0.0.0.0:1229 0.0.0.0:* 7850/fence_virtd

在这里插入图片描述
关闭火墙

stonith_admin -a fence_xvm -M
#启用stonith
pcs stonith create vmfence fence_xvm pcmk_host_map="server2:vm2;server3:rhel7.6" op  monitor interval=60s
#配置节点
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值