金鱼哥RHCA回忆录:RH236扩缩容volumes--缩容volume

举报
金鱼哥 发表于 2022/05/27 09:22:26 2022/05/27
【摘要】 第七章 扩缩容volumes--缩容volume

本章节介绍如何对GlusterFS进行缩容volumes。


🎹 个人简介:大家好,我是 金鱼哥,CSDN运维领域新星创作者,华为云·云享专家,阿里云社区·专家博主
📚个人资质:CCNA、HCNP、CSNA(网络分析师),软考初级、中级网络工程师、RHCSA、RHCE、RHCA、RHCI、ITIL😜
💬格言:努力不一定成功,但要想成功就必须努力🔥


缩容volume

途径:将brick从volume中剔除,实现缩容

注意:

剔除的brick个数,要考虑剔除之后,数据会不会丢,移除Replicate类型的brick数据不会丢失。


1) 移除Replicate类型的brick

需要指明移除后replica的数量,并且直接使用force指令直接执行。

# gluster volume remove-brick vol1 replica 1 \ 
node1:/brick/brick1/brick \ 
force

可能出现的报错:

volume remove-brick start: failed: Remove exactly 1 brick(s) from each subvolume.

出现这个报错主要是由于删除带有Replicate类型的复合卷时,命令内指明删除的brick存在有相同的Replicate的brick。

解决办法:相同的Replicate brick具有相同的trusted.glusterfs.dht目录扩展属性,

通过查看trusted.glusterfs.dht来修改需要剔除的目录。

# getfattr -d -m ".*" /brick/brick1/brick1 
getfattr: Removing leading '/' from absolute path names 
# file: brick/brick1/brick1 
security.selinux="system_u:object_r:unlabeled_t:s0" 
trusted.gfid=0sAAAAAAAAAAAAAAAAAAAAAQ== 
trusted.glusterfs.dht=0sAAAAAQAAAAB//////////w== 
trusted.glusterfs.dht.commithash="3634901324" 
trusted.glusterfs.volume-id=0sf1W8jgybTceZGk4fsq4eew==

2)移除非Replicate类型的volume

# gluster volume remove-brick vol1 replica 1 \ 
node1:/brick/brick1/brick \ 
start 
#这种方式,不会改变原有类型,但可能会丢失数据

查看移除状态:

# gluster volume remove-brick vol1 node1:/brick/brick1/brick status


移除完成之后,要进行提交操作

# gluster volume remove-brick vol1 node1:/brick/brick1/brick commit


移除操作的场景:

当有服务器down的时候,为了保证glusterfs工作正常,需要将多余server移除


课本练习

[root@workstation ~]# lab shrinkvolume setup 
Setting up servers for lab exercise work:

 • Testing if all hosts are reachable..........................  SUCCESS
 • Adding glusterfs to runtime firewall on servera.............  SUCCESS
 • Adding glusterfs to permanent firewall on servera...........  SUCCESS
 • Adding glusterfs to runtime firewall on serverb.............  SUCCESS
 • Adding glusterfs to permanent firewall on serverb...........  SUCCESS
 • Adding glusterfs to runtime firewall on serverc.............  SUCCESS
 • Adding glusterfs to permanent firewall on serverc...........  SUCCESS
 • Adding glusterfs to runtime firewall on serverd.............  SUCCESS
 • Adding glusterfs to permanent firewall on serverd...........  SUCCESS
 • Adding servera to trusted storage pool......................  SUCCESS
…………

1. 在您的servera系统上,检查shrinkme卷的布局,并确定可以删除哪两个块。

[root@servera ~]# gluster volume info shrinkme 
Volume Name: shrinkme
Type: Distributed-Replicate
Volume ID: ea91e5b1-b57b-4d72-a5e9-2c8c3d94677d
Status: Started
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: servera:/bricks/brick-a2/brick
Brick2: serverb:/bricks/brick-b2/brick
Brick3: serverc:/bricks/brick-c2/brick
Brick4: serverd:/bricks/brick-d2/brick
Options Reconfigured:
performance.readdir-ahead: on

2. 缩容brick-c2和brick-d2

[root@servera ~]# gluster volume remove-brick shrinkme serverc:/bricks/brick-c2/brick serverd:/bricks/brick-d2/brick start
volume remove-brick start: success
ID: 667f7585-a9c4-43e8-8f3b-0482bfb19d97

[root@servera ~]# gluster volume remove-brick shrinkme serverc:/bricks/brick-c2/brick serverd:/bricks/brick-d2/brick status
                                    Node Rebalanced-files          size       scanned      failures       skipped               status   run time in secs
                               ---------      -----------   -----------   -----------   -----------   -----------         ------------     --------------
                 serverc.lab.example.com                7        0Bytes             7             0             0            completed               1.00
                 serverd.lab.example.com                0        0Bytes             0             0             0            completed               0.00

[root@servera ~]# gluster volume remove-brick shrinkme serverc:/bricks/brick-c2/brick serverd:/bricks/brick-d2/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.

3. 脚本评分

[root@workstation ~]# lab shrinkvolume grade


rebalance总结

值得注意的是,在扩容GlusterFS后,需要手动执行gluster rebalance命令来触发数据均衡功能。扩容后会带来新旧节点数据不均衡的问题,进一步发展可能会导致旧节点负载过高而出现性能问题,甚至最终影响到数据可靠性和可用性,因此,扩容后进行数据均衡是非常必要的。

而在缩容GlusterFS后,并不需要手动执行命令,缩容时会自动触发执行数据均衡过程,这是因为如果缩容时没有自动进行数据均衡,那么被剔除掉的节点或子卷上的数据将不再可用,从而会导致数据的丢失,这对于用户来说是不可接受的,因此数据均衡在缩容时是不可或缺的,程序实现采用自动触发方式也就理所当然了。


章节实验

[root@workstation ~]# lab extendvolume-lab setup 
Setting up servers for lab exercise work:

 • Testing if all hosts are reachable..........................  SUCCESS
 • Adding glusterfs to runtime firewall on servera.............  SUCCESS
 • Adding glusterfs to permanent firewall on servera...........  SUCCESS
 • Adding glusterfs to runtime firewall on serverb.............  SUCCESS
 • Adding glusterfs to permanent firewall on serverb...........  SUCCESS
 • Adding glusterfs to runtime firewall on serverc.............  SUCCESS
 • Adding glusterfs to permanent firewall on serverc...........  SUCCESS
 • Adding glusterfs to runtime firewall on serverd.............  SUCCESS
 • Adding glusterfs to permanent firewall on serverd...........  SUCCESS
 • Adding servera to trusted storage pool......................  SUCCESS
…………

1. 按要求进行扩容。

[root@servera ~]# gluster volume info important 
Volume Name: important
Type: Distribute
Volume ID: b4500b45-891c-41ea-b198-3b9467b9f197
Status: Started
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: servera:/bricks/brick-a3/brick
Brick2: serverb:/bricks/brick-b3/brick
Options Reconfigured:
performance.readdir-ahead: on
[root@servera ~]# gluster volume add-brick important replica 2 serverc:/bricks/brick-c3/brick serverd:/bricks/brick-d3/brick
volume add-brick: success

[root@servera ~]# gluster volume rebalance important start
volume rebalance: important: success: Rebalance on important has been started successfully. Use rebalance status command to check status of the rebalance process.
ID: b1f99fb3-3155-430a-b30e-f6ed3e73d603

[root@servera ~]# gluster volume rebalance important status
                                    Node Rebalanced-files          size       scanned      failures       skipped               status   run time in secs
                               ---------      -----------   -----------   -----------   -----------   -----------         ------------     --------------
                               localhost                0        0Bytes            49             0             0            completed               1.00
                 serverb.lab.example.com                0        0Bytes            51             0             0            completed               1.00
                 serverc.lab.example.com                0        0Bytes             0             0             0            completed               0.00
                 serverd.lab.example.com                0        0Bytes             0             0             0            completed               0.00
volume rebalance: important: success

2. 脚本评分

[root@workstation ~]# lab extendvolume-lab grade


3. 重置环境

reset workstation,servera,serverb,serverc,serverd


总结

  • 介绍如何进行缩容volume。

  • 了解执行数据均衡过程。

RHCA认证需要经历5门的学习与考试,还是需要花不少时间去学习与备考的,好好加油,可以噶🤪。

以上就是【金鱼哥】对 第七章 扩缩容volumes–缩容volume 的简述和讲解。希望能对看到此文章的小伙伴有所帮助。

💾红帽认证专栏系列:
RHCSA专栏:戏说 RHCSA 认证
RHCE专栏:戏说 RHCE 认证
此文章收录在RHCA专栏:RHCA 回忆录

如果这篇【文章】有帮助到你,希望可以给【金鱼哥】点个赞👍,创作不易,相比官方的陈述,我更喜欢用【通俗易懂】的文笔去讲解每一个知识点。

如果有对【运维技术】感兴趣,也欢迎关注❤️❤️❤️ 【金鱼哥】❤️❤️❤️,我将会给你带来巨大的【收获与惊喜】💕💕!

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。