服务器信息

hostnameipglusterfs peer
k8s-master192.168.31.21no
k8s-node1192.168.31.22yes
k8s-node2192.168.31.23yes
k8s-node3192.168.31.24yes

在k8s-node1,k8s-node2,k8s-node3上配置磁盘,本人使用的是virtualbox虚拟机,额外挂在一块磁盘

lsblk
mkfs.xfs -f /dev/sdb
mkdir /glusterfs
mount /dev/sdb /glusterfs
mkdir -p /glusterfs/replica

记录sdb的UUID

lsblk -o NAME,UUID,MOUNTPOINT,FSTYPE
vi /etc/fstab

追加

UUID={sdb UUID} /glusterfs      xfs     defaults          0       2

在k8s-node1,k8s-node2,k8s-node3上安装glusterfs-server

sudo apt -y install glusterfs-server
sudo systemctl enable --now glusterd
gluster --version

在k8s-node1上,追加peer

gluster peer probe k8s-node2
gluster peer probe k8s-node3
gluster peer status

在k8s-node1上,创建volume replica

gluster volume create vol_replica replica 3 transport tcp \
k8s-node1:/glusterfs/replica \
k8s-node2:/glusterfs/replica \
k8s-node3:/glusterfs/replica
gluster volume start vol_replica
gluster volume info

在k8s-master上,安装glusterfs-client测试

sudo apt -y install glusterfs-client
mkdir -p /mnt/vol_replica
mount -t glusterfs k8s-node1:/vol_replica /mnt/vol_replica
df -hT

完结!

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐