Centos7.9安装Gluster存储

操作节点为192.168.8.137
yum -y install centos-release-gluster -y
yum -y install glusterfs-server -y
systemctl start glusterd.service 
systemctl enable glusterd.service 
systemctl status glusterd.service 
添加节点 node136
[root@gfs137 ~]# gluster peer probe node136
peer probe: success. 
[root@gfs137 ~]# gluster pool list
UUID					Hostname 	State
01dd3146-d829-47e8-82e9-723aab62158d	node136  	Connected 
dda3c0cd-53d1-4485-a5f3-f09bc664bcc4	localhost	Connected 
目录/data/gfs1,/data/gfs136 需要在各节点创建

(force参数是因为不是驱动设备所以强制使用)

[root@gfs137 ~]# gluster volume create  k8s_data gfs137:/data/k8s node136:/data/k8s  force 
volume create: k8s_data: success: please start the volume to access data

启动节点查看状态

[root@gfs137 ~]# gluster volume start k8s_data 
volume start: k8s_data: success
[root@gfs137 ~]# gluster volume info  k8s_data 
 
Volume Name: k8s_data
Type: Distribute
Volume ID: dabbd700-6bfb-4846-9492-a6a5e99e60af
Status: Started
Snapshot Count: 0
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: gfs137:/data/k8s
Brick2: node136:/data/k8s
Options Reconfigured:
transport.address-family: inet
storage.fips-mode-rchecksum: on
nfs.disable: on
管理卷
#停止卷
gluster volume  stop k8s_data
 
#删除卷
gluster volume delete  k8s_data
 
rm -rf /data/k8s_data
#查看节点状态
gluster  volume status

在这里插入图片描述

客户端测试

yum -y install centos-release-gluster -y
yum install -y glusterfs glusterfs-fuse
[root@BBC ~]# mount -t glusterfs 192.168.8.136:/jbjbge /mnt/
[root@BBC ~]# df -h
文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               224M     0  224M    0% /dev
tmpfs                  235M     0  235M    0% /dev/shm
tmpfs                  235M  5.5M  229M    3% /run
tmpfs                  235M     0  235M    0% /sys/fs/cgroup
/dev/sda3               47G  1.8G   46G    4% /
/dev/sda1             1014M  142M  873M   14% /boot
tmpfs                   47M     0   47M    0% /run/user/0
192.168.8.136:/k8s_data   47G  2.3G   45G    5% /mnt


常用命令

gluster peer probe #增加一个节点,参数为主机名或IP
gluster peer detach #删除指定的节点,后跟主机名或IP
gluster peer status #列出切点的状态
gluster peer help #关于gluster peer命令的帮助信息

复制式卷

 #test-k8s 这个是卷的名称
#replica 3  表示是三份副本,也就是一份数据写三分
#目前支持比较好的是2或者3副本,事实上个人觉得3最好了,性能上还可以接受,安全上比2要好,因为是无中心的,2个brick复制可能脑裂的几率会比较大。
#每个节点的目录。
#node1:/data/gluster node2:/data/gluster node3:/data/gluster
#force 强制
gluster volume create test-k8s  replica 3 master-01-k8s:/data/gluster master-02-k8s:/data/gluster master-03-k8s:/data/gluster force

分布式复制式卷

这个模式比较的重要,企业开发中,一般会使用这个模式。执行添加卷的时候,一定要确保挂载的目录存在,不然,就会报错。

mkdir -p /data/gluster2
#创建备份
[root@gfs137 ~]# gluster volume create k8s_rc replica 2 gfs137:/data/gluster2 node136:/data/gluster2 force
volume create: k8s_rc: success: please start the volume to access data

#k8s_data 这个是卷的名称
#replica 2  表示是两份副本,也就是一份数据写两份副本
#每个节点的目录。
#
#force 强制到新节点
gluster  volume  add-brick k8s_rc replica 2  node3:/data/gluster2  node4:/data/gluster2 force
#启动卷
gluster volume start k8s_rc
 
#停止卷
gluster volume  stop k8s_rc
#查看节点状态
gluster  volume status
 
#查看卷的情况
gluster volume info k8s_rc

猜你喜欢

转载自blog.csdn.net/weixin_42562106/article/details/112914788