-
在實體主機上,安裝 fence device server 套件:
[root@fence ~]# yum -y install fence-virtd fence-virtd-libvirt fence-virtd-multicast
-
在實體主機上,產生 fence_xvm.key:
[root@fence ~]# mkdir /etc/cluster
[root@fence ~]# cd /etc/cluster
[root@fence ~]# dd if=/dev/urandom of=/etc/cluster/fence_xvm.key bs=4k count=1
-
將 fence_xvm.key 複製到各VM上:
[root@fence ~]# ssh nodea
[root@nodea ~]# mkdir /etc/cluster ; exit
[root@fence ~]# scp /etc/cluster/fence_xvm.key nodea:/etc/cluster
-
利用指令設定 fence_virtd 設定檔 /etc/fence_virt.conf:
[root@fence ~]# fence_virtd -c
(注意下列設定,其餘保持預設值:)
interface: [br0] (與虚擬機通訊的網路卡介面)
key path: [/etc/cluster/fence_xvm.key]
-
檢查檔案 /etc/fence_virt.conf 內容:
[root@fence ~]# vim /etc/fence_virt.conf
backends {
libvirt {
uri = "qemu:///system";
}
}
listeners {
multicast {
port = "1229";
family = "ipv4";
interface = "br0";
address = "225.0.0.12";
key_file = "/etc/cluster/fence_xvm.key";
}
}
fence_virtd {
module_path = "/usr/lib64/fence-virt";
backend = "libvirt";
listener = "multicast";
}
-
啟動 fence-virtd 服務:
[root@fence ~]# systemctl enable fence_virtd
[root@fence ~]# systemctl start fence_virtd
-
開啟防火牆與SELinux設定:
[root@fence ~]# firewall-cmd --permanent --add-port=1229/tcp
[root@fence ~]#firewall-cmd --permanent --add-port=1229/udp
[root@fence ~]#firewall-cmd --reload
[root@fence ~]#setsebool -P fenced_can_network_connect on
[root@fence ~]#setsebool -P fenced_can_ssh on