CentOS7安装GlusterFS
GlusterFS简介
参考:https://blog.51cto.com/13447608/2386830?source=dra
GlusterFS安装
如下所示三台机器,hostname分别是node-1/node-2/node-3,在/etc/hosts添加3台机器的主机名解析,关闭selinux、防火墙、NetworkManager等。
node-1 | 10.0.0.1 |
node-2 | 10.0.0.2 |
node-3 | 10.0.0.3 |
安装glusterfs(三台都要执行)
#安装glusterfs yum install centos-release-gluster yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma #启动gluster服务 systemctl start glusterd.service systemctl enable glusterd.service
在node-1上执行,将node-2、node-3加入集群
gluster peer probe node-2 gluster peer probe node-3
在node-1上看集群状态
[root@node-1 db]# gluster peer status Number of Peers: 2 Hostname: node-2 Uuid: d8d232f-e5fb-4752-b40d-b0103afrf8ea State: Peer in Cluster (Connected) Hostname: node-3 Uuid: ff3gg732-ae12-4b6c-4rfb-65fd7886588c State: Peer in Cluster (Connected)
在node-1上执行,创建3副本的复制卷。glusterfs使用现有Linux文件系统创建glusterfs文件系统。
#创建卷
[root@node-1 ~]# gluster volume create app-data replica 3 transport tcp node-1:/gfs-data/ node-2:/gfs-data/ node-3:/gfs-data/ force volume create: app-data: success: please start the volume to access data
# 列出卷
[root@k8sm0 ~]# gluster volume list
app-data
# 查看卷信息
[root@node-1 ~]# gluster volume info
Volume Name: app-data
Type: Replicate
Volume ID: rr2068b2-0da6-431f-8f93-3d7b2f331gde
Status: Created
Snapshot Count: 0
Number of Bricks: 1 x 3 = 3
Transport-type: tcp
Bricks:
Brick1: node-1:/gfs-data
Brick2: node-2:/gfs-data
Brick3: node-3:/gfs-data
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
performance.client-io-threads: off
# 启动卷
[root@node-1 ~]# gluster volume start app-data
volume start: app-data: success
[root@node-1 ~]# gluster volume quota app-data enable
volume quota : success
[root@node-1 ~]# gluster volume quota app-data limit-usage / 10GB
volume quota : success
# 查看卷状态
[root@node-1 app]# gluster volume status
Status of volume: app-data
Gluster process TCP Port RDMA Port Online Pid
------------------------------------------------------------------------------
Brick node-1:/gfs-data 49152 0 Y 6283
Brick node-2:/gfs-data 49152 0 Y 6216
Brick node-3:/gfs-data 49152 0 Y 6232
#挂载
[root@node-1 ~]# mkdir /gfs-share && mount -t glusterfs localhost:k8s-data /gfs-share
[root@node-1 ~]# echo "localhost:app-data /gfs-share/ glusterfs defaults 0 0" >> /etc/fstab