1. 安裝所需的軟體源
yum config-manager --set-enabled ol9_addons
2. 安裝所需的軟體
yum install -y pacemaker corosync pcs
3. 編寫corosync配置檔案
檔案路徑:/etc/corosync/corosync.conf
totem {
version: 2
cluster_name: mycluster
transport: udpu
}
nodelist {
node {
name: glusterfs-01
ring0_addr: 10.0.0.120
nodeid: 1
}
node {
name: glusterfs-02
ring0_addr: 10.0.0.173
nodeid: 2
}
}
quorum {
provider: corosync_votequorum
}
logging {
to_syslog: yes
}
4. 配置服務
設定服務啟動(每個節點都執行)
sudo systemctl start pcsd
sudo systemctl enable pcsd
sudo systemctl start corosync
sudo systemctl enable corosync
sudo systemctl start pacemaker
sudo systemctl enable pacemaker
需要移除
http_proxy
和https_proxy
設定叢集管理員密碼(每個節點都執行)
passwd hacluster
其中一個節點上認證叢集管理員
pcs host auth node1 node2 -u hacluster -p <管理員密碼>
驗證corosync配置
pcs cluster authkey corosync
啟動叢集
pcs cluster start --all
建立NFS-Ganasha資源
pcs resource create nfs-ganesha systemd:nfs-ganesha op monitor interval=30s
建立虛擬ip
pcs resource create virtual_ip ocf:heartbeat:IPaddr2 ip=10.0.0.10 cidr_netmask=24 op monitor interval=30s
需要將虛擬ip更換為你自己的,我的網段是10.0.0.0
設定資源組
pcs resource group add nfs_group virtual_ip nfs-ganesha
psc resource enable nfs_group
禁用 STONITH(如果不需要)
pcs property set stonith-enabled=false
驗證配置
pcs status