一、 GlusterFS卷维护

1.1 GlusterFS的常用操作

卷的常用操作命令
创建卷gluster volume create
启动卷gluster volume start
停止卷gluster volume stop
删除卷gluster volume delete
添加节点gluster peer probe
删除节点gluster peer detach
列出集群中的所有卷gluster volume list
查看集群中的卷信息gluster volume info
查看集群中的卷状态gluster volume statu

1.2 扩容卷

先添主机到主机池中

  1. gluster peer probe server3
  2. gluster peer probe server4

创建目录

在server3和server4上创建目录

mkdir /data/glusterfs -p

扩容节点并增加复制份数

  • data是卷名
  1. gluster volume add-brick data replica 2 server3:/data/glusterfs server4:/data/glusterfs

查看

  1. [root@server1 ~]# gluster volume info data
  2. Volume Name: data
  3. Type: Distributed-Replicate
  4. Volume ID: a99e0ecc-132d-4778-8cc8-36b9a2c04ac4
  5. Status: Started
  6. Snapshot Count: 0
  7. Number of Bricks: 2 x 2 = 4
  8. Transport-type: tcp
  9. Bricks:
  10. Brick1: server1:/data/glusterfs
  11. Brick2: server2:/data/glusterfs
  12. Brick3: server3:/data/glusterfs
  13. Brick4: server4:/data/glusterfs
  14. Options Reconfigured:
  15. transport.address-family: inet
  16. nfs.disable: on

1.3 收缩节点

执行缩卷命令

  • data是卷名
  1. gluster volume remove-brick data server3:/data/glusterfs server4:/data/glusterfs start

查看迁移状态

  1. [root@server1 ~]# gluster volume remove-brick data server3:/data/glusterfs server4:/data/glusterfs status
  2. Node Rebalanced-files size scanned failures skipped status run time in h:m:s
  3. --------- ----------- ----------- ----------- ----------- ----------- ------------ --------------
  4. server3 0 0Bytes 0 0 0 completed 0:00:00
  5. server4 0 0Bytes 0 0 0 completed 0:00:00
  • 当status状态显示completed时就表示好了

提交

  1. gluster volume remove-brick data server3:/data/glusterfs server4:/data/glusterfs commit

查看状态

  1. [root@server1 ~]# gluster volume info
  2. Volume Name: data
  3. Type: Replicate
  4. Volume ID: a99e0ecc-132d-4778-8cc8-36b9a2c04ac4
  5. Status: Started
  6. Snapshot Count: 0
  7. Number of Bricks: 1 x 2 = 2
  8. Transport-type: tcp
  9. Bricks:
  10. Brick1: server1:/data/glusterfs
  11. Brick2: server2:/data/glusterfs
  12. Options Reconfigured:
  13. transport.address-family: inet
  14. nfs.disable: on

1.4 GlusterFS目录迁移

创建迁移目录

mkdir /data/backup -p

迁移

gluster volume replace-brick data server1:/data/glusterfs server1:/data/backup commit force

查看结果

  1. [root@server1 ~]# gluster volume info
  2. Volume Name: data
  3. Type: Distributed-Replicate
  4. Volume ID: a99e0ecc-132d-4778-8cc8-36b9a2c04ac4
  5. Status: Started
  6. Snapshot Count: 0
  7. Number of Bricks: 2 x 2 = 4
  8. Transport-type: tcp
  9. Bricks:
  10. Brick1: server1:/data/backup
  11. Brick2: server2:/data/glusterfs
  12. Brick3: server3:/data/glusterfs
  13. Brick4: server4:/data/glusterfs
  14. Options Reconfigured:
  15. nfs.disable: on
  16. transport.address-family: inet

二、 GlusterFS常用的优化

2.1 GlusterFS常用优化参数

配置选项用途默认值合法值
network.ping-timeout客户端等待检查服务器是否响应的持续时间,节点挂了数据不能写入420-42
Performance.cache-refresh-timeout缓存校验周期1s0-61
auth.allow允许访问卷的客户端ip
auth.reject拒接访问卷的客户端ip
performance.cache-size读取缓存的大小32 MB
performance.write-behind-window-size能提高写性能单个文件后写缓冲区的大小1MB
performance.io-thread-countIO操作的最大线程160-65

官方参数

  • 修改语句的命令格式 gluster volume set <VOLNAME>

  • 例如

GlusterFS集群会有一个检测时间默认是42s,如果一个节点挂了或网络不通了,整个集群都会在这42秒内无法写入数据,所以通常会修改这个检测时间。

  • 把它改成10s
  1. [root@server1 ~]# gluster volume set data network.ping-timeout 10
  2. volume set: success