金鱼哥RHCA回忆录:RH236创建Brick
本章节学习和演示创建Brick,都是运用前比较重要的环节,而且要有LVM的基础上进行。
🎹 个人简介:大家好,我是 金鱼哥,CSDN运维领域新星创作者,华为云·云享专家,阿里云社区·专家博主
📚个人资质:CCNA、HCNP、CSNA(网络分析师),软考初级、中级网络工程师、RHCSA、RHCE、RHCA、RHCI、ITIL😜
💬格言:努力不一定成功,但要想成功就必须努力🔥
创建过程:
disk ----> pv ----> vg ----> lv —> 格式化 ----> 挂载 ----> 导出
使用LVM瘦卷的其中一个原因:快照功能需要使用精简卷(瘦卷)支持
1. 创建lv
# pvcreate /dev/sdb
# vgcreate -s 4M vg1 /dev/sdb
注:-s表示设置每个PE的大小,默认大小为4M,若底层PV采用RAID-6,则建议使用1280k
# lvcreate -L 10G -T vg1/pool
注:从vg1里划分10G的空间,作成一个瘦池,叫pool
-T,表示创建一个thinpool(精简池,瘦池)
所谓瘦池,就是说这个空间,将来是用多少占多少
# lvcreate -V 2G -T vg1/pool -n brick1
注:从vg1/pool这个瘦池中划分2G的空间,创建一个lv,名字叫brick1
-V,表示这是一个虚拟空间,也就是从瘦池里分的空间,就是虚拟的
2. 格式化挂载
# mkfs.xfs -i size=512 /dev/mapper/vg1-brick1
#格式化成xfs
#-i,指定inode大小,默认大小265字节,官方建议512字节,(性能优化章节:Chapter 13. Configuring Red Hat Gluster Storage for Enhancing Performance,第243页)
# mkdir -p /brick/brick1
# echo "/dev/mapper/vg1-brick1 /brick/brick1 xfs defaults 0 0" >> /etc/fstab
# mount -a
3. 设置selinux
# semanage fcontext -a -t glusterd_brick_t /brick/brick1
# restorecon -Rv /bricks
4. 导出
不用手工导出brick,当创建volume的时候,会自动导出
注意:导出目录不能是挂载点,所以必须在挂载点下创建一个目录作为导出目录mkdir /brick/brick1/brick
课本练习
[student@workstation ~]$ lab setup-bricks setup
Testing if server and serverb are ready for lab exercise work:
• Testing if servera is reachable............................. PASS
• Testing if serverb is reachable............................. PASS
• Testing runtime firewall on servera for glusterfs........... PASS
• Testing permanent firewall on servera for glusterfs......... PASS
• Testing runtime firewall on serverb for glusterfs........... PASS
• Testing permanent firewall on serverb for glusterfs......... PASS
• Testing if glusterd is active on servera.................... PASS
• Testing if glusterd is active on serverb.................... PASS
• Testing if glusterd is active on servera.................... PASS
• Testing if glusterd is active on serverb.................... PASS
• Testing if both servera and serverb are in pool............. PASS
Overall setup status:.......................................... PASS
1. 在vg_bricks卷组中创建一个10gib LVM瘦池,名为thinpool。
[root@servera ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/vdb vg_bricks lvm2 a-- 20.00g 20.00g
[root@servera ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_bricks 1 0 0 wz--n- 20.00g 20.00g
[root@servera ~]# lvcreate -L 10G -T vg_bricks/thinpool
Logical volume "thinpool" created.
[root@servera ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
thinpool vg_bricks twi-a-tz-- 10.00g 0.00 0.62
[root@serverb ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/vdb vg_bricks lvm2 a-- 20.00g 20.00g
[root@servera ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_bricks 1 0 0 wz--n- 20.00g 20.00g
[root@serverb ~]# lvcreate -L 10G -T vg_bricks/thinpool
Logical volume "thinpool" created.
[root@serverb ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
thinpool vg_bricks twi-a-tz-- 10.00g 0.00 0.62
2. 使用vg_bricks/thinpool LVM瘦池创建一个虚拟大小为2 GiB的逻辑卷,分别称为brick-a1和brick-b1。
[root@servera ~]# lvcreate -V 2G -T vg_bricks/thinpool -n brick-a1
Logical volume "brick-a1" created.
[root@servera ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
brick-a1 vg_bricks Vwi-a-tz-- 2.00g thinpool 0.00
thinpool vg_bricks twi-aotz-- 10.00g 0.00 0.65
[root@serverb ~]# lvcreate -V 2G -T vg_bricks/thinpool -n brick-b1
Logical volume "brick-b1" created.
[root@serverb ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
brick-b1 vg_bricks Vwi-a-tz-- 2.00g thinpool 0.00
thinpool vg_bricks twi-aotz-- 10.00g 0.00 0.65
3. 在brick-a1和brick-b1逻辑卷上创建一个inode为512字节的XFS文件系统。
[root@servera ~]# mkfs.xfs -i size=512 /dev/vg_bricks/brick-a1
meta-data=/dev/vg_bricks/brick-a1 isize=512 agcount=8, agsize=65520 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=524160, imaxpct=25
= sunit=16 swidth=16 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=16 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@serverb ~]# mkfs.xfs -i size=512 /dev/vg_bricks/brick-b1
meta-data=/dev/vg_bricks/brick-b1 isize=512 agcount=8, agsize=65520 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=524160, imaxpct=25
= sunit=16 swidth=16 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=16 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
4. 分别创建目录/brick /brick-al和/brick /brick-b1,然后持久地挂载bricks。
[root@servera ~]# mkdir -p /bricks/brick-a1
[root@servera ~]# blkid
/dev/vda1: UUID="2460ab6e-e869-4011-acae-31b2e8c05a3b" TYPE="xfs"
/dev/sr0: UUID="2016-03-04-05-19-32-00" LABEL="RHGSS-3.1.2 RHEL-7 RHGSS.x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/vdb: UUID="KlhHmY-vcmo-8qHh-nkio-soPV-8yIS-zoQPpg" TYPE="LVM2_member"
/dev/mapper/vg_bricks-brick--a1: UUID="7ac737ca-277a-40e7-bc95-52fa0dfae255" TYPE="xfs"
[root@servera ~]# echo "UUID=7ac737ca-277a-40e7-bc95-52fa0dfae255 /bricks/brick-a1 xfs defaults 1 2" >> /etc/fstab
[root@servera ~]# mount -a
[root@servera ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 xfs 10G 1.6G 8.5G 16% /
devtmpfs devtmpfs 902M 0 902M 0% /dev
tmpfs tmpfs 920M 0 920M 0% /dev/shm
tmpfs tmpfs 920M 25M 896M 3% /run
tmpfs tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs tmpfs 184M 0 184M 0% /run/user/0
/dev/mapper/vg_bricks-brick--a1 xfs 2.0G 33M 2.0G 2% /bricks/brick-a1
[root@serverb ~]# mkdir -p /bricks/brick-b1
[root@serverb ~]# blkid
/dev/vda1: UUID="2460ab6e-e869-4011-acae-31b2e8c05a3b" TYPE="xfs"
/dev/vdb: UUID="KlhHmY-vcmo-8qHh-nkio-soPV-8yIS-zoQPpg" TYPE="LVM2_member"
/dev/mapper/vg_bricks-brick--b1: UUID="65d56a32-e951-49ea-b094-4b5bd292d8c5" TYPE="xfs"
[root@serverb ~]# echo "UUID=65d56a32-e951-49ea-b094-4b5bd292d8c5 /bricks/brick-b1 xfs defaults 1 2" >> /etc/fstab
[root@serverb ~]# mount -a
[root@serverb ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 xfs 10G 1.7G 8.4G 17% /
devtmpfs devtmpfs 902M 0 902M 0% /dev
tmpfs tmpfs 920M 0 920M 0% /dev/shm
tmpfs tmpfs 920M 105M 816M 12% /run
tmpfs tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs tmpfs 184M 0 184M 0% /run/user/0
/dev/mapper/vg_bricks-brick--b1 xfs 2.0G 33M 2.0G 2% /bricks/brick-b1
5. 在servera和serverb上,在新bricks上创建/brick子目录。
[root@servera ~]# mkdir /bricks/brick-a1/brick
[root@serverb ~]# mkdir /bricks/brick-b1/brick
6. 为创建的brick目录配置默认的SELinux标签为glusterd_brick_t,然后重新标记bricks目录。
[root@servera ~]# semanage fcontext -a -t glusterd_brick_t /bricks/brick-a1/brick
[root@servera ~]# restorecon -Rv /bricks
restorecon reset /bricks/brick-a1 context system_u:object_r:unlabeled_t:s0->system_u:object_r:default_t:s0
restorecon reset /bricks/brick-a1/brick context unconfined_u:object_r:unlabeled_t:s0->unconfined_u:object_r:glusterd_brick_t:s0
[root@serverb ~]# semanage fcontext -a -t glusterd_brick_t /bricks/brick-b1/brick
[root@serverb ~]# restorecon -Rv /bricks
restorecon reset /bricks/brick-b1 context system_u:object_r:unlabeled_t:s0->system_u:object_r:default_t:s0
restorecon reset /bricks/brick-b1/brick context unconfined_u:object_r:unlabeled_t:s0->unconfined_u:object_r:glusterd_brick_t:s0
7. 评分脚本
[student@workstation ~]$ lab setup-bricks grade
总结
-
要确保LVM的基础知识,是创建brick的前提。
-
谨记需要配置thinpool(精简池,瘦池)。
RHCA认证需要经历5门的学习与考试,还是需要花不少时间去学习与备考的,好好加油,可以噶🤪。
以上就是【金鱼哥】对 第三章 配置红帽GLUSTER存储–创建Brick 的简述和讲解。希望能对看到此文章的小伙伴有所帮助。
💾红帽认证专栏系列:
RHCSA专栏:戏说 RHCSA 认证
RHCE专栏:戏说 RHCE 认证
此文章收录在RHCA专栏:RHCA 回忆录
如果这篇【文章】有帮助到你,希望可以给【金鱼哥】点个赞👍,创作不易,相比官方的陈述,我更喜欢用【通俗易懂】的文笔去讲解每一个知识点。
如果有对【运维技术】感兴趣,也欢迎关注❤️❤️❤️ 【金鱼哥】❤️❤️❤️,我将会给你带来巨大的【收获与惊喜】💕💕!
- 点赞
- 收藏
- 关注作者
评论(0)