proxmox ve 部署双节点HA集群及glusterfs分布式文件系统
需要保存两个pve节点的版本一样
两个proxmox ve节点,实现高可用vm,lxc自动迁移
修改hosts文件
在两台pve的/etc/hosts中,增加如下host
| 1
2
3
4
 | 192.168.1.229 pve1.local pve1
192.168.1.230 pve2.local pve2
192.168.1.229 gluster1
192.168.1.230 gluster2
 | 
 
安装glusterfs
以下操作都在两台机器上做, 这里分别为pve1, pve2
| 1
2
3
4
5
6
7
8
 | wget -O - https://download.gluster.org/pub/gluster/glusterfs/9/rsa.pub | apt-key add -
DEBID=$(grep 'VERSION_ID=' /etc/os-release | cut -d '=' -f 2 | tr -d '"')
DEBVER=$(grep 'VERSION=' /etc/os-release | grep -Eo '[a-z]+')
DEBARCH=$(dpkg --print-architecture)
echo deb https://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/${DEBID}/${DEBARCH}/apt ${DEBVER} main > /etc/apt/sources.list.d/gluster.list
apt update && apt install -y glusterfs-server
 | 
 
需要保存gluster的版本一样
如果一样,请升级,我有一台是9.2,加了源也没不会直接升级到10.3,需要这样做:
| 1
 | apt-get list -a glusterfs-server
 | 
 
会出现全部的版本,然后安装对应的
| 1
 | apt-get install glusterfs-server="10.3-1"
 | 
 
在pve1上编辑: nano /etc/glusterfs/glusterd.vol, 在 option transport.socket.listen-port 24007 增加:
| 1
2
3
 |     option transport.rdma.bind-address gluster1
    option transport.socket.bind-address gluster1
    option transport.tcp.bind-address gluster1
 | 
 
在pve2上编辑: nano /etc/glusterfs/glusterd.vol, 在 option transport.socket.listen-port 24007 增加:
| 1
2
3
 |     option transport.rdma.bind-address gluster2
    option transport.socket.bind-address gluster2
    option transport.tcp.bind-address gluster2
 | 
 
开启服务
| 1
2
 | systemctl enable glusterd.service
systemctl start glusterd.service
 | 
 
重要,在pve2上需要执行命令以加入集群
| 1
 | gluster peer probe gluster1
 | 
 
显示: peer probe: success 就OK
增加volume
这里直接建立在zfs上,保证两台pve都使用一样的路径建立volume,这里的路径是/tank/gfs
注意如果是zfs的话,不要能使用挂载根目前,而要使用目录, 下面例子中,/tank/gfs就是一个zfs的挂载,在下面建立了一个子目录s来用作volume
| 1
2
3
 | gluster volume create VMS replica 2 gluster1:/tank/gfs/s gluster2:/tank/gfs/s
gluster vol start VMS
 | 
 
检查状态
| 1
2
 | gluster vol info VMS
gluster vol status VMS
 | 
 
增加挂载
在两台pve上都要做
修改pve1的/etc/fstab,增加
| 1
 | gluster1:VMS /vms glusterfs defaults,_netdev,x-systemd.automount,backupvolfile-server=gluster2 0 0
 | 
 
修改pve2的/etc/fstab,增加
| 1
 | gluster2:VMS /vms glusterfs defaults,_netdev,x-systemd.automount,backupvolfile-server=gluster1 0 0
 | 
 
重启两台pve,让/mnt挂载
两台pve不重启挂载
解决split-brain问题
两个节点的gluster会出现split-brain问题,就是两节点票数一样,谁也不听谁的,解决办法如下:
| 1
2
3
4
5
6
7
8
 | gluster vol set vms cluster.heal-timeout 5
gluster volume heal vms enable
gluster vol set vms cluster.quorum-reads false
gluster vol set vms cluster.quorum-count 1
gluster vol set vms network.ping-timeout 2
gluster volume set vms cluster.favorite-child-policy mtime
gluster volume heal vms granular-entry-heal enable
gluster volume set vms cluster.data-self-heal-algorithm full
 | 
 
pve双节点集群设置
第一个创建,第二个加入,没什么好说的
创建共享目录
在DataCenter中的Storage中,点Add,Directory填/vms, 钩选 share
HA设置
修改 /etc/pve/corosync.conf
在quorum中增加,变成这样:
| 1
2
3
4
5
 | quorum {
    provider: corosync_votequorum
    expected_votes: 1
    two_node: 1
}
 | 
 
其中, expected_votes表示希望的节点数量, two_node: 1表示,只有两个节点,还有一个wait_for_all: 0, NOTES: enabling two_node: 1 automatically enables wait_for_all. It is still possible to override wait_for_all by explicitly setting it to 0. If more than 2 nodes join the cluster, the two_node option is automatically disabled.