莫问 发表于 2019-2-1 10:45:56

GlusterFS 安装与配置

  GlusterFS是一个开源的分布式文件系统,于2011年被红帽收购.它具有高扩展性、高性能、高可用性、可横向扩展的弹性特点,无元数据服务器设计使glusterfs没有单点故障隐患,详细介绍请查看官网:www.gluster.org 。
  部署环境:

  OS: CentOS>  Server:
  c1:192.168.242.132
  c2:192.168.242.133
  c3:192.168.242.134
  c4:192.168.242.135
  hosts:
  192.168.242.132 c1
  192.168.242.133 c2
  192.168.242.134 c3
  192.168.242.135 c4
  具体操作:
  c1/c2/c3/c4上执行
  # wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo
  # yum install -y glusterfs glusterfs-server glusterfs-fuse
  # /etc/init.d/glusterd start
  Starting glusterd: [ OK ]
  # chkconfig glusterd on
  c1上配置集群
  # gluster peer probe c1
  peer probe: success. Probe on localhost not needed
  # gluster peer probe c2
  peer probe: success.
  # gluster peer probe c3
  peer probe: success.
  # gluster peer probe c4
  peer probe: success.
  如果c1在peer表中被识别为ip地址,可能后面集群过程中会出现通讯问题,
  我们可以使用ip来进行修复:
  # gluster peer status
  Number of Peers: 3
  Hostname: 192.168.242.132
  Uuid: 6e8d6880-ec36-4331-a806-2e8fb4fda7be
  State: Peer in Cluster (Connected)
  Hostname: c2
  Uuid: 9a722f50-911e-4181-823d-572296640486
  State: Peer in Cluster (Connected)
  Hostname: c4
  Uuid: 1ee3588a-8a16-47ff-ba59-c0285a2a95bd
  State: Peer in Cluster (Connected)
  # gluster peer detach 192.168.242.132
  peer detach: success
  # gluster peer probe c1
  peer probe: success.
  # gluster peer status
  Number of Peers: 3
  Hostname: c2
  Uuid: 9a722f50-911e-4181-823d-572296640486
  State: Peer in Cluster (Connected)
  Hostname: c4
  Uuid: 1ee3588a-8a16-47ff-ba59-c0285a2a95bd
  State: Peer in Cluster (Connected)
  Hostname: c1
  Uuid: 6e8d6880-ec36-4331-a806-2e8fb4fda7be
  State: Peer in Cluster (Connected)
  c1上创建集群磁盘
  # gluster volume create datavolume1 replica 2 transport tcp c1:/usr/local/share/datavolume1 c2:/usr/local/share/datavolume1 c3:/usr/local/share/datavolume1 c4:/usr/local/share/datavolume1 force
  volume create: datavolume1: success: please start the volume to access data
  # gluster volume create datavolume2 replica 2 transport tcp c1:/usr/local/share/datavolume2 c2:/usr/local/share/datavolume2 c3:/usr/local/share/datavolume2 c4:/usr/local/share/datavolume2 force
  volume create: datavolume2: success: please start the volume to access data
  # gluster volume create datavolume3 replica 2 transport tcp c1:/usr/local/share/datavolume3 c2:/usr/local/share/datavolume3 c3:/usr/local/share/datavolume3 c4:/usr/local/share/datavolume3 force
  volume create: datavolume3: success: please start the volume to access data
  # gluster volume start datavolume1
  volume start: datavolume1: success
  # gluster volume start datavolume2
  volume start: datavolume2: success
  # gluster volume start datavolume3
  volume start: datavolume3: success
  # gluster volume info
  Volume Name: datavolume1
  Type: Distributed-Replicate

  Volume>  Status: Started
  Number of Bricks: 2 x 2 = 4
  Transport-type: tcp
  Bricks:
  Brick1: c1:/usr/local/share/datavolume1
  Brick2: c2:/usr/local/share/datavolume1
  Brick3: c3:/usr/local/share/datavolume1
  Brick4: c4:/usr/local/share/datavolume1
  Volume Name: datavolume2
  Type: Distributed-Replicate

  Volume>  Status: Started
  Number of Bricks: 2 x 2 = 4
  Transport-type: tcp
  Bricks:
  Brick1: c1:/usr/local/share/datavolume2
  Brick2: c2:/usr/local/share/datavolume2
  Brick3: c3:/usr/local/share/datavolume2
  Brick4: c4:/usr/local/share/datavolume2
  Volume Name: datavolume3
  Type: Distributed-Replicate

  Volume>  Status: Started
  Number of Bricks: 2 x 2 = 4
  Transport-type: tcp
  Bricks:
  Brick1: c1:/usr/local/share/datavolume3
  Brick2: c2:/usr/local/share/datavolume3
  Brick3: c3:/usr/local/share/datavolume3
  Brick4: c4:/usr/local/share/datavolume3
  客户端环境部署
  Centos OS 6.5 x64 并加入hosts
  #wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo
  #yum install -y glusterfs glusterfs-fuse
  # mkdir -p /mnt/{datavolume1,datavolume2,datavolume3}
  # mount -t glusterfs -o ro c1:datavolume1 /mnt/datavolume1/
  # mount -t glusterfs -o ro c1:datavolume2 /mnt/datavolume2/
  # mount -t glusterfs -o ro c1:datavolume3 /mnt/datavolume3/
  me3
  # df -h

  Filesystem>  /dev/mapper/VolGroup-lv_root
  38G 840M 36G 3% /
  tmpfs 242M 0 242M 0% /dev/shm
  /dev/sda1 485M 32M 429M 7% /boot
  c1:datavolume1 57G 2.4G 52G 5% /mnt/datavolume1
  c1:datavolume2 57G 2.4G 52G 5% /mnt/datavolume2
  c1:datavolume3 57G 2.4G 52G 5% /mnt/datavolume3
  客户端测试
  # umount /mnt/datavolume1/
  # mount -t glusterfs c1:datavolume1 /mnt/datavolume1/
  # touch /mnt/datavolume1/test.txt
  # ls /mnt/datavolume1/test.txt
  /mnt/datavolume1/test.txt
  # ls -al /usr/local/share/datavolume1/
  total 16
  drwxr-xr-x. 3 root root 4096 May 15 03:50 .
  drwxr-xr-x. 8 root root 4096 May 15 02:28 ..
  drw——-. 6 root root 4096 May 15 03:50 .glusterfs
  -rw-r–r–. 2 root root 0 May 20 2014 test.txt
  # ls -al /usr/local/share/datavolume1/
  total 16
  drwxr-xr-x. 3 root root 4096 May 15 03:50 .
  drwxr-xr-x. 8 root root 4096 May 15 02:28 ..
  drw——-. 6 root root 4096 May 15 03:50 .glusterfs
  -rw-r–r–. 2 root root 0 May 20 2014 test.txt
  删除GlusterFS磁盘:
  gluster volume stop datavolume1
  gluster volume delete datavolume1
  卸载GlusterFS磁盘:

  gluster peer detach>  访问控制:
  gluster volume set datavolume1 auth.allow 192.168.242.*,192.168.241.*
  添加GlusterFS节点:
  gluster peer probe c6
  gluster peer probe c7
  gluster volume add-brick datavolume1 c6:/usr/local/share/datavolume1 c7:/usr/local/share/datavolume1
  迁移GlusterFS磁盘数据:
  gluster volume remove-brick datavolume1 c1:/usr/local/share/datavolume1 c6:/usr/local/share/datavolume1 start
  gluster volume remove-brick datavolume1 c1:/usr/local/share/datavolume1 c6:/usr/local/share/datavolume1 status
  gluster volume remove-brick datavolume1 c1:/usr/local/share/datavolume1 c6:/usr/local/share/datavolume1 commit
  数据重新分配:
  gluster volume rebalance datavolume1 start
  gluster volume rebalance datavolume1 status
  gluster volume rebalance datavolume1 stop
  修复GlusterFS磁盘数据(例如在c1宕机的情况下):
  gluster volume replace-brick datavolume1 c1:/usr/local/share/datavolume1 c6:/usr/local/share/datavolume1 commit -force
  gluster volume heal datavolume1 full
  转自:http://www.btschina.com/home/index.php/glusterfs-an-zhuang-yu-pei-zhi.html

页: [1]
查看完整版本: GlusterFS 安装与配置