Glusterfs 扩容缩减

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Glusterfs 扩容缩减相关的知识,希望对你有一定的参考价值。


        对于一个存储,不可避免的会遇到扩容、缩减存储容量的问题。

1 为Glusterfs扩容

提前准备好了一个gluster volume:

[[email protected] ~]# gluster volume info repvol
 
Volume Name: repvol
Type: Replicate
Volume ID: 7015b7fe-8039-4d5d-b698-e8321df5289c
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node01.lab.example.com:/bricks/thinvol1/brick
Brick2: node02.lab.example.com:/bricks/thinvol1/brick
Options Reconfigured:
performance.stat-prefetch: off
storage.batch-fsync-delay-usec: 0
server.allow-insecure: on
performance.readdir-ahead: on
transport.address-family: inet
nfs.disable: on

可以看出repvol是一个包含2个brick的1x2复制卷,将repvol挂载到node02 server上,并写入一些数据以作测试。

[[email protected] ~]# mount -t cifs //node01.lab.example.com/gluster-repvol -o user=smbuser,pass=redhat /mnt
[[email protected] ~]# cd /mnt
[[email protected] mnt]# ls
[[email protected] mnt]# touch {1..100}.file

使用如下命令为repvol再增加两个brick

[[email protected] ~]# gluster volume add-brick repvol node01.lab.example.com:/bricks/thinvol2/brick node02.lab.example.com:/bricks/thinvol2/brick
volume add-brick: success
[[email protected] ~]# gluster volume info repvol
 
Volume Name: repvol
Type: Distributed-Replicate
Volume ID: 7015b7fe-8039-4d5d-b698-e8321df5289c
Status: Started
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node01.lab.example.com:/bricks/thinvol1/brick
Brick2: node02.lab.example.com:/bricks/thinvol1/brick
Brick3: node01.lab.example.com:/bricks/thinvol2/brick
Brick4: node02.lab.example.com:/bricks/thinvol2/brick
Options Reconfigured:
performance.stat-prefetch: off
storage.batch-fsync-delay-usec: 0
server.allow-insecure: on
performance.readdir-ahead: on
transport.address-family: inet
nfs.disable: on

可以看到repvol已经变成了一个2x2的分布式复制卷,扩容后我们还需要把原有的数据rebalance

[[email protected] ~]# gluster volume rebalance repvol start
volume rebalance: repvol: success: Rebalance on repvol has been started successfully. Use rebalance status command to check status of the rebalance process.
ID: a8fba779-6c2d-449b-8847-58aeb2ae1798
[[email protected] ~]# gluster volume rebalance repvol status
                                    Node Rebalanced-files          size       scanned      failures       skipped               status  run time in h:m:s
                               ---------      -----------   -----------   -----------   -----------   -----------         ------------     --------------
                               localhost               48        0Bytes           100             0             0            completed        0:0:5
                                  node02                0        0Bytes             0             0             0            completed        0:0:2
volume rebalance: repvol: success

这里有一个需要注意的地方,当数据量太大的时候,对数据进行rebalance必须要考虑的一个问题就是性能,不能因为数据rebalance而影响我们的存储的正常使用。Glusterfs也考虑到了这个问题,在进行数据rebalance时,根据实际场景不同设计了三种不同的“级别”:

1)lazy:每次仅可以迁移一个文件
2)normal:默认设置,每次迁移2个文件或者是(CPU逻辑个数-4)/2,哪个大,选哪个
3)aggressive:每次迁移4个文件或者是(CPU逻辑个数-4)/2

通过以下命令进行配置:

 gluster volume set VOLUME-NAME cluster.rebal-throttle [lazy|normal|aggressive]

如将volume repvol设置为lazy

[[email protected] ~]# gluster volume set repvol cluster.rebal-throttle lazy
volume set: success


2 缩减volume大小

将我们刚刚添加的2个brick再从volume repovl中删掉

[[email protected] ~]# gluster volume remove-brick repvol node01.lab.example.com:/bricks/thinvol2/brick node02.lab.example.com:/bricks/thinvol2/brick start
volume remove-brick start: success
ID: db72aaf8-e60d-4e56-be60-54469df9c233
[[email protected] ~]# gluster volume remove-brick repvol node01.lab.example.com:/bricks/thinvol2/brick node02.lab.example.com:/bricks/thinvol2/brick status
                                    Node Rebalanced-files          size       scanned      failures       skipped               status  run time in h:m:s
                               ---------      -----------   -----------   -----------   -----------   -----------         ------------     --------------
                               localhost               48        0Bytes           101             0             0            completed        0:0:3
                                  node02                0        0Bytes             0             0             0            completed        0:0:1
[[email protected] ~]# gluster volume remove-brick repvol node01.lab.example.com:/bricks/thinvol2/brick node02.lab.example.com:/bricks/thinvol2/brick commit
Removing brick(s) can result in data loss. Do you want to Continue? (y/n) y
volume remove-brick commit: success
Check the removed bricks to ensure all files are migrated.
If files with data are found on the brick path, copy them via a gluster mount point before re-purposing the removed brick.

此时再看repvol已经重新变为1x2的复制卷了

[[email protected] ~]# gluster volume info repvol
 
Volume Name: repvol
Type: Replicate
Volume ID: 7015b7fe-8039-4d5d-b698-e8321df5289c
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node01.lab.example.com:/bricks/thinvol1/brick
Brick2: node02.lab.example.com:/bricks/thinvol1/brick
Options Reconfigured:
cluster.rebal-throttle: lazy
performance.stat-prefetch: off
storage.batch-fsync-delay-usec: 0
server.allow-insecure: on
performance.readdir-ahead: on
transport.address-family: inet
nfs.disable: on
[[email protected] ~]# ls /bricks/thinvol1/brick/ | wc -w
100


本文出自 “不积跬步,无以至千里” 博客,请务必保留此出处http://jiaxiaolei.blog.51cto.com/3117381/1951535

以上是关于Glusterfs 扩容缩减的主要内容,如果未能解决你的问题,请参考以下文章

(转载) Linux LVM分区之VG扩容LV扩容LV缩减LVM快照

Tidb进行缩减扩容tikv节点

LVM的创建扩容和缩减

基于CentOS 6 系统创建逻辑卷LVM,执行扩容,缩减,删除等操作

LVM逻辑卷-创建扩容缩减迁移快照

glusterfs集群