Welcome 微信登录

首页 / 操作系统 / Linux / CentOS 7 搭建GlusterFS

实验需求
  • 4台机器安装GlusterFS组成一个集群
  • 客户端把docker registry存储到文件系统里
  • 4个节点的硬盘空间不整合成一个硬盘空间,要求每个节点都存储一份,保证数据安全
环境规划servernode1:192.168.0.165  主机名:glusterfs1node2:192.168.0.157  主机名:glusterfs2node3:192.168.0.166  主机名:glusterfs3node4:192.168.0.150  主机名:glusterfs4client192.168.0.164      主机名:master3实验前准备
  • 所有主机关闭防火墙,SElinux
  • 修改hosts文件,能够互相解析
192.168.0.165  glusterfs1192.168.0.157  glusterfs2192.168.0.166  glusterfs3192.168.0.150  glusterfs4192.168.0.164  master3安装服务端1.在glusterfs {1-4}节点上安装GlusrerFS软件包# wget -P /etc/yum.repos.d# yum install -y glusterfs glusterfs-server glusterfs-fuse# service gluterd start# chkconfig gluterd on2.在glusterfs1节点上配置整个GlusterFS集群,把各个节点加入到集群[root@glusterfs1 ~]# gluster peer probe glusterfs11 peer probe: success: on localhost not needed[root@glusterfs1 ~]# gluster peer probe glusterfs21 peer probe: success[root@glusterfs1 ~]# gluster peer probe glusterfs21 peer probe: success[root@glusterfs1 ~]# gluster peer probe glusterfs2 1 peer probe: success3.查看节点状态[root@glusterfs1 ~]#gluster peer status4.在glusterfs{1-4}上创建数据存储目录# mkdir -p  /usr/local/share/models5.在glusterfs1上创建GlusterFS磁盘注意:加上replica 4就是4个节点中,每个节点都要把数据存储一次,就是一个数据存储4份,每个节点一份如果不加replica 4,就是4个节点的磁盘空间整合成一个硬盘,[root@glusterfs1 ~]#gluster volume create models replica 4 glusterfs1:/usr/local/share/models glusterfs2:/usr/local/share/models glusterfs3:/usr/local/share/models glusterfs4:/usr/local/share/models force1 volume create: models: success: please start the volume to access data6.启动[root@glusterfs1 ~]# gluster volume start models客户端1.部署GlusterFS客户端并mount GlusterFS文件系统[root@master3 ~]# wget -P /etc/yum.repos.d[root@master3 ~]# yum install -y glusterfs glusterfs-fuse[root@master3 ~]# mkdir -p /mnt/models[root@master3 ~]# mount -t glusterfs -o ro glusterfs1:models /mnt/models/2.查看效果[root@master3 ~]# df -hFilesystem       Size  Used Avail Use% Mounted on/dev/vda3          289G  5.6G  284G 2% /devtmpfs         3.9G   0  3.9G 0% /devtmpfs              3.9G 80K  3.9G 1% /dev/shmtmpfs              3.9G  169M  3.7G 5% /runtmpfs              3.9G   0  3.9G 0% /sys/fs/cgroup/dev/vda1       1014M  128M  887M  13% /bootglusterfs1:models  189G  3.5G  186G 2% /mnt/models其他操作命令删除GlusterFS磁盘# gluster volume stop models 先停止# gluster volume delete models 再删除卸载GlusterFS磁盘gluster peer detach glusterfs4ACL访问控制gluster volume set models auth.allow 10.60.1.*,10.70.1.*添加GlusterFS节点# gluster peer probe sc2-log5# gluster peer probe sc2-log6# gluster volume add-brick models sc2-log5:/data/gluster sc2-log6:/data/gluster迁移GlusterFS数据# gluster volume remove-brick models sc2-log1:/usr/local/share/models sc2-log5:/usr/local/share/models start# gluster volume remove-brick models sc2-log1:/usr/local/share/models sc2-log5:/usr/local/share/models status# gluster volume remove-brick models sc2-log1:/usr/local/share/models sc2-log5:/usr/local/share/models commit修复GlusterFS数据(在节点1宕机的情况下)# gluster volume replace-brick models sc2-log1:/usr/local/share/models sc2-log5:/usr/local/share/models commit -force# gluster volume heal models full使用GlusterFS作为KVM后端存储 http://www.linuxidc.com/Linux/2013-08/89108.htm分布式存储系统GlusterFS初体验 http://www.linuxidc.com/Linux/2013-08/89107.htmGlusterFS全局统一命名空间 http://www.linuxidc.com/Linux/2013-08/89106.htm设计新Xlator扩展GlusterFS http://www.linuxidc.com/Linux/2013-08/89105.htmGlusterFS Rebalance简析 http://www.linuxidc.com/Linux/2013-08/89104.htmCentOS 6.0-x86_64下体验Glusterfs  http://www.linuxidc.com/Linux/2015-01/111211.htmGlusterFS 的详细介绍:请点这里
GlusterFS 的下载地址:请点这里本文永久更新链接地址