Linux企业实战-----fence实现虚拟机断电自动重启

server1、server2:

systemctl start pcsd
systemctl enable pcsd
pcs cluster start --all
yum install fence-virt.x86_64 -y
pcs stonith describe fence_virt
pcs stonith list
mkdir /etc/cluster

home:

yum install -y fence-virtd.x86_64 fence-virtd-libvirt.x86_64   fence-virtd-multicast.x86_64 
fence_virtd -c     (此步骤中需将网卡设置为ens33,别的步骤直接跳过)
mkdir /etc/cluster
cd /etc/cluster/
dd if=/dev/urandom of=fence_xvm.key bs=128 count=1    创建key文件
systemctl restart fence_virtd.service 
netstat -anlpu|grep 1229
systemctl disable --now firewalld
scp fence_xvm.key server1:/etc/cluster
scp fence_xvm.key server2:/etc/cluster

server1、server2:
pcs property set stonith-enabled=true
#集群节点添加fence
pcs stonith create vmfence fence_xvm pcmk_host_map="server1:server1;server2:server2" op monitor interval=60s
pcs status

Linux企业实战-----fence实现虚拟机断电自动重启_第1张图片

此时中断服务或者关闭网卡,虚拟机都会自动重启

 

你可能感兴趣的:(Linux企业实战)