设为首页 收藏本站
查看: 997|回复: 0

[经验分享] CentOS 7 搭建GlusterFS

[复制链接]

尚未签到

发表于 2019-2-1 10:33:06 | 显示全部楼层 |阅读模式
  CentOS 7 搭建GlusterFS
  实验需求:
  4台机器安装GlusterFS组成一个集群
  客户端把docker registry存储到文件系统里
  4个节点的硬盘空间不整合成一个硬盘空间,要求每个节点都存储一份,保证数据安全
  环境规划
  -----------------------------------------------------
  server
  -----------------------------------------------------
  node1:192.168.56.11  主机名:glusterfs1
  -----------------------------------------------------
  node2:192.168.56.12  主机名:glusterfs2
  -----------------------------------------------------
  node3:192.168.56.13  主机名:glusterfs3
  -----------------------------------------------------
  node4:192.168.56.14  主机名:glusterfs4
  -----------------------------------------------------
  client
  -----------------------------------------------------
  192.168.56.20         主机名:client
  -----------------------------------------------------
  OS: BCLinux release 7.2 (Mars)
  实验前准备:
  所有主机关闭防火墙,SElinux修改hosts文件,能够互相解析
  192.168.56.11  glusterfs1
  192.168.56.12  glusterfs2
  192.168.56.13  glusterfs3
  192.168.56.14  glusterfs4
  192.168.56.20  client
  。SSH互信(最好选择主机名)
  -->ssh-keygen -t rsa
  -->ssh-copy-id -i /root/.ssh/id_rsa.pub root@glusterfs1
  -->ssh-copy-id -i /root/.ssh/id_rsa.pub root@glusterfs2
  -->ssh-copy-id -i /root/.ssh/id_rsa.pub root@glusterfs3
  -->ssh-copy-id -i /root/.ssh/id_rsa.pub root@glusterfs4
  -->ssh-copy-id -i /root/.ssh/id_rsa.pub root@client
  一、安装
  服务端
  1.在glusterfs {1-4}节点上安装GlusrerFS软件包
  。Glusterfs下载地址:
  http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-3.7.17-1.el7.x86_64.rpm
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-api-3.7.17-1.el7.x86_64.rpm
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-cli-3.7.17-1.el7.x86_64.rpm
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-client-xlators-3.7.17-1.el7.x86_64.rpm
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-debuginfo-3.7.17-1.el7.x86_64.rpm
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-fuse-3.7.17-1.el7.x86_64.rpm
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-geo-replication-3.7.17-1.el7.x86_64.rpm
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-libs-3.7.17-1.el7.x86_64.rpm
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-rdma-3.7.17-1.el7.x86_64.rpm
  wget https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.17/CentOS/epel-7.2/x86_64/glusterfs-server-3.7.17-1.el7.x86_64.rpm
  安装:
  -->yum install libibverbs librdmacm -y
  -->wget http://dl.fedoraproject.org/pub/epel/6/x86_64//userspace-rcu-0.7.7-1.el6.x86_64.rpm
  -->rpm -ivh userspace-rcu-0.7.7-1.el6.x86_64.rpm
  -->yum localinstall *.rpm -y
  ----------------------------------------------------------------------------------------------
  报错:
  需要:liburcu-bp.so.1()(64bit)
  错误:依赖检测失败:
  libibverbs.so.1()(64bit) 被 glusterfs-rdma-3.7.17-1.el7.x86_64 需要
  libibverbs.so.1(IBVERBS_1.0)(64bit) 被 glusterfs-rdma-3.7.17-1.el7.x86_64 需要
  libibverbs.so.1(IBVERBS_1.1)(64bit) 被 glusterfs-rdma-3.7.17-1.el7.x86_64 需要
  librdmacm.so.1()(64bit) 被 glusterfs-rdma-3.7.17-1.el7.x86_64 需要
  librdmacm.so.1(RDMACM_1.0)(64bit) 被 glusterfs-rdma-3.7.17-1.el7.x86_64 需要
  liburcu-bp.so.1()(64bit) 被 glusterfs-server-3.7.17-1.el7.x86_64 需要
  liburcu-cds.so.1()(64bit) 被 glusterfs-server-3.7.17-1.el7.x86_64 需要
  解决方法:
  -->yum install libibverbs librdmacm -y
  -->wget http://dl.fedoraproject.org/pub/epel/6/x86_64//userspace-rcu-0.7.7-1.el6.x86_64.rpm
  -->rpm -ivh userspace-rcu-0.7.7-1.el6.x86_64.rpm
  ----------------------------------------------------------------------------------------------
  3.userspace-rcu下载地址:
  -->wget http://dl.fedoraproject.org/pub/epel/7/x86_64/u/userspace-rcu-0.7.16-1.el7.x86_64.rpm
  -->rpm -ivh serspace-rcu-0.7.16-1.el7.x86_64.rpm
  安装:
  -->yum localinstall *.rpm
  。查看安装的版本
  -->glusterfs -V
  glusterfs 3.7.17 built on Nov  3 2016 14:29:48
  Repository revision: git://git.gluster.com/glusterfs.git
  Copyright (c) 2006-2013 Red Hat, Inc.
  GlusterFS comes with ABSOLUTELY NO WARRANTY.
  It is licensed to you under your choice of the GNU Lesser
  General Public License, version 3 or any later version (LGPLv3
  or later), or the GNU General Public License, version 2 (GPLv2),
  in all cases as published by the Free Software Foundation.
  。启动glusterfs服务
  -->systemctl enable glusterd.service
  Created symlink from /etc/systemd/system/multi-user.target.wants/glusterd.service to /usr/lib/systemd/system/glusterd.service.
  -->systemctl start gluterd.service
  -->systemctl status glusterd.service
  ● glusterd.service - GlusterFS, a clustered file-system server
  Loaded: loaded (/usr/lib/systemd/system/glusterd.service; enabled; vendor preset: disabled)
  Active: active (running) since Sun 2017-07-09 16:20:51 CST; 30s ago
  Process: 4684 ExecStart=/usr/sbin/glusterd -p /var/run/glusterd.pid --log-level $LOG_LEVEL $GLUSTERD_OPTIONS (code=exited, status=0/SUCCESS)
  Main PID: 4685 (glusterd)
  CGroup: /system.slice/glusterd.service
  └─4685 /usr/sbin/glusterd -p /var/run/glusterd.pid --log-level INFO
  Jul 09 16:20:48 glusterfs1 systemd[1]: Starting GlusterFS, a clustered file-system server...
  Jul 09 16:20:51 glusterfs1 systemd[1]: Started GlusterFS, a clustered file-system server.
  2.在glusterfs1节点上配置整个GlusterFS集群,把各个节点加入到集群
  -->gluster peer probe glusterfs1
  peer probe: success. Probe on localhost not needed
  -->gluster peer probe glusterfs2
  peer probe: success.
  -->gluster peer probe glusterfs3
  peer probe: success.
  -->gluster peer probe glusterfs4
  peer probe: success.
  3.查看节点状态
  -->gluster peer status
  Number of Peers: 3
  Hostname: glusterfs2
  Uuid: 9149c992-e86c-436d-8da9-b2a7245289cb
  State: Peer in Cluster (Connected)
  Hostname: glusterfs3
  Uuid: dcbe562d-5bbd-4ee8-8855-c48428bba7ef
  State: Peer in Cluster (Connected)
  Hostname: glusterfs4
  Uuid: 677514f3-7c3c-4b8e-b93d-db3941485166
  State: Peer in Cluster (Connected)
  4.在glusterfs{1-4}上创建数据存储目录
  -->mkdir -p  /usr/local/share/models
  5.在glusterfs1上创建GlusterFS磁盘
  注意:
  加上replica 4就是4个节点中,每个节点都要把数据存储一次,就是一个数据存储4份,每个节点一份
  如果不加replica 4,就是4个节点的磁盘空间整合成一个硬盘,
  -->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 force
  volume create: models: success: please start the volume to access data
  6.启动
  -->gluster volume start models
  volume start: models: success
  ----------------------------------------------------------------------------
  客户端
  1.部署GlusterFS客户端并mount GlusterFS文件系统
  -->mkdir /usr/local/src/rpm
  方法同服务器端(下载rpm安装)
  -->yum install libibverbs librdmacm -y
  -->wget http://dl.fedoraproject.org/pub/epel/6/x86_64//userspace-rcu-0.7.7-1.el6.x86_64.rpm
  -->rpm -ivh userspace-rcu-0.7.7-1.el6.x86_64.rpm
  -->yum localinstall *.rpm -y
  最好按下面方法安装客户端包
  -->rpm -ivh glusterfs-client-xlators-3.7.17-1.el7.x86_64.rpm glusterfs-fuse-3.7.17-1.el7.x86_64.rpm
  -->mkdir -p /mnt/models
  -->mount -t glusterfs -o ro glusterfs1:models /mnt/models/
  2.查看效果
  -->df -h
  df -hT
  Filesystem        Type            Size  Used Avail Use% Mounted on
  /dev/sda2         ext4             50G  1.5G   46G   4% /
  devtmpfs          devtmpfs        904M     0  904M   0% /dev
  tmpfs             tmpfs           913M     0  913M   0% /dev/shm
  tmpfs             tmpfs           913M  8.8M  904M   1% /run
  tmpfs             tmpfs           913M     0  913M   0% /sys/fs/cgroup
  /dev/sda6         ext4             35G  4.7G   29G  15% /var
  /dev/sda3         ext4            9.8G   37M  9.2G   1% /home
  /dev/sda1         ext4            477M   94M  354M  21% /boot
  tmpfs             tmpfs           183M     0  183M   0% /run/user/0
  glusterfs1:models fuse.glusterfs   50G  1.5G   46G   4% /mnt/models
  其他操作命令
  。删除GlusterFS磁盘
  -->gluster volume stop  models  先停止
  -->gluster volume delete models  再删除
  。卸载GlusterFS磁盘
  -->gluster peer detach glusterfs4
  。ACL访问控制
  -->gluster volume set models auth.allow 192.168.56.*,10.0.1.*
  volume set: success
  。添加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




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-670355-1-1.html 上篇帖子: CentOS 6.5安装部署Glusterfs 下篇帖子: GlusterFS 存储结构原理介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表