hha 发表于 2015-9-10 03:41:16

CentOS6.4安装GlusterFS

  主机分配:
  主机名             IP(Static)                        系统                                           配置                        角色

  gfs-server01    192.168.20.21    CentOS-6.4-x86_64-minimal         2CPU,4G,50G,1网卡          存储节点01

  gfs-server02    192.168.20.22    CentOS-6.4-x86_64-minimal         2CPU,4G,50G,1网卡          存储节点02
  gfs-client          192.168.20.20    CentOS-6.4-x86_64-minimal         2CPU,4G,50G,1网卡            客户端
  GlusterFS rpm下载地址:
  http://download.gluster.org/pub/gluster/glusterfs/LATEST/RHEL/epel-6/x86_64/

  Server端操作(192.168.20.21/22)
  1.安装

  (1).下载GlusterFS yum源:
  # yum -y install wget
  # wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo
  (2).安装Gluster server:
  # yum -y install glusterfs-server glusterfs
  (3).启动Gluster server服务:
  # service glusterd start
  # chkconfig glusterd on
  gfs-server02采用同样步骤。
  2.配置
  (1).将两个存储节点添加到一个集群中,在其中一个存储节点操作即可,不用添加本机:

  # gluster peer probe 192.168.20.21
  (2).检查集群节点信息
  # gluster peer status
  Number of Peers: 1
  Hostname: 192.168.20.21
  Uuid: 81e52f87-9671-4f21-9e18-0213b4f4f2c9
  State: Peer in Cluster (Connected)
  #
  3440805e-95b0-4383-b59d-a58d1a79ab74
  (3).以/data/gluster为共享目录,创建名为volume-sql的卷,副本数为2

  # gluster volume create volume-sql replica 2 192.168.20.21:/data/gluster 192.168.20.22:/data/gluster
  (4).启动卷
  # gluster volume start volume-sql
  (5).查看卷状态
  # gluster volume info
  
  Volume Name: volume-sql
  Type: Replicate
  Volume ID: a9fea762-0b46-4a0b-aa8f-27d21bd258d2
  Status: Started
  Number of Bricks: 1 x 2 = 2
  Transport-type: tcp
  Bricks:
  Brick1: 192.168.20.21:/data/gluster
  Brick2: 192.168.20.22:/data/gluster
  

  Client端操作(192.168.20.20)

  1.安装
  (1).下载GlusterFS yum源:
  # yum -y install wget
  # wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo
(2).安装Gluster client:
# yum -y install glusterfs glusterfs-fuse
  2.挂载
  (1).创建挂载目录

  # mkdir -p /openstack/mysql
  (2).使用glusterfs挂载(挂载任意一个储存节点即可)

  # mount -t glusterfs 192.168.20.21:/volume-sql /openstack/mysql
  # echo "192.168.20.21:/volume-sql /openstack/mysql glusterfs defaults,_netdev 0 0" >> /etc/fstab
  (3).使用NFS挂载(注意远端的rpcbind服务必须开启)
  # mount -t nfs -o mountproto=tcp,vers=3 192.168.20.21:/volume-sql /openstack/mysql
  # echo "192.168.20.21:/volume-sql /openstack/mysql nfs mountproto=tcp,vers=3 0 0“
  3.测试
  (1).拷贝文件到/openstack/mysql/
  # cp -av /root/centos6.4_20G.qcow2 /openstack/mysql/
  (2).存储节点上查看文件:
  # ls /data/gluster/
  centos6.4_20G.qcow2
  # md5sum /data/gluster/centos6.4_20G.qcow2
  94469f217dbe3cc54ebe2771b31d0fee/data/gluster/centos6.4_20G.qcow2
  # ls /data/gluster/
# md5sum /data/gluster/centos6.4_20G.qcow2
94469f217dbe3cc54ebe2771b31d0fee/data/gluster/centos6.4_20G.qcow2
  4.常用命令
  (1).删除卷

  # gluster volume stop volume-sql
  # gluster volume delete volume-sql
  (2).将存储节点移除集群
  # gluster peer detach 192.168.20.23
  (3).允许某些网段访问某个卷
  # gluster volume set volume-sql auth.allow 192.168.20.*
  (4).添加新存储节点到集群
  # gluster peer probe 192.168.20.24
  # gluster peer probe 192.168.20.25
  # gluster volume add-brick volume-sql 192.168.20.24:/data/gluster 192.168.20.25:/data/gluster
  (5).收缩卷
  先迁移数据到其他位置:
  # gluster volume remove-brick volume-sql 192.168.20.26:/data/gluster/volume-sql 192.168.20.27:/data/gluster/volume-sql start
  查看数据迁移状态:

  # gluster volume remove-brick volume-sql 192.168.20.26:/data/gluster/volume-sql 192.168.20.27:/data/gluster/volume-sql status
  迁移完成后提交:
  # gluster volume remove-brick volume-sql 192.168.20.26:/data/gluster/volume-sql 192.168.20.27:/data/gluster/volume-sql commit
  (6).迁移卷
  添加存储节点:

  # gluster peer probe 192.168.20.28
  开始卷迁移:
  # gluster volume replace-brick volume-sql 192.168.20.21:/data/gluster/volume-sql 192.168.20.28:/data/gluster/volume-sql start
  查看迁移状态:
  # gluster volume replace-brick volume-sql 192.168.20.21:/data/gluster/volume-sql 192.168.20.28:/data/gluster/volume-sql status
  迁移完毕后提交:

  # gluster volume replace-brick volume-sql 192.168.20.21:/data/gluster/volume-sql 192.168.20.28:/data/gluster/volume-sql commit
  如果机器192.168.20.21出现故障已经不能运行,执行强制提交然后Gluster马上执行一次同步:
  # gluster volume replace-brick img 192.168.20.21:/data/gluster/volume-sql 192.168.20.28:/data/gluster/volume-sql commit -force
  # gluster volume heal imgs full
  
页: [1]
查看完整版本: CentOS6.4安装GlusterFS