1.创建逻辑卷。
在servera上,lvcreate -L 10G -T vg_bricks/thinpool从vg_bricks卷组中创建名为thinpool且大小为10G的逻辑卷, lvdisplay查看逻辑卷信息,vgdisplay查看卷组信息。serverb按照类似操作。
[root@servera ~]# lvcreate -L 10G -T vg_bricks/thinpool
Logical volume "thinpool" created.
[root@servera ~]# lvdisplay
--- Logical volume ---
LV Name thinpool
VG Name vg_bricks
LV UUID PPqAH3-EvW7-vtUn-OLI1-OB3v-mtBC-xouLUK
LV Write Access read/write
LV Creation host, time servera.lab.example.com, 2019-01-21 11:53:05 +0800
LV Pool metadata thinpool_tmeta
LV Pool data thinpool_tdata
LV Status available
# open 0
LV Size 10.00 GiB
Allocated pool data 0.00%
Allocated metadata 0.62%
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:2
[root@servera ~]# vgdisplay
--- Volume group ---
VG Name vg_bricks
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 20.00 GiB
PE Size 4.00 MiB
Total PE 5119
Alloc PE / Size 2566 / 10.02 GiB
Free PE / Size 2553 / 9.97 GiB
VG UUID goAyUK-iQk0-RQLW-F1Os-h72o-30r0-pjJ5cV
[root@serverb ~]# lvcreate -L 10G -T vg_bricks/thinpool
Logical volume "thinpool" created.
[root@serverb ~]# lvdisplay
--- Logical volume ---
LV Name thinpool
VG Name vg_bricks
LV UUID dZYpaz-Kril-KzM6-pCYQ-83qG-T92s-aH1Sp0
LV Write Access read/write
LV Creation host, time serverb.lab.example.com, 2019-01-21 11:54:02 +0800
LV Pool metadata thinpool_tmeta
LV Pool data thinpool_tdata
LV Status available
# open 0
LV Size 10.00 GiB
Allocated pool data 0.00%
Allocated metadata 0.62%
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:2
[root@serverb ~]# vgdisplay
--- Volume group ---
VG Name vg_bricks
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 20.00 GiB
PE Size 4.00 MiB
Total PE 5119
Alloc PE / Size 2566 / 10.02 GiB
Free PE / Size 2553 / 9.97 GiB
VG UUID goAyUK-iQk0-RQLW-F1Os-h72o-30r0-pjJ5cV
2.二次分配逻辑卷
在servera上,lvcreate -V 2G -T vg_bricks/thinpool -n brick-a1虚拟化2G空间给brick-a1。lvdisplay显示裸机卷信息。serverb类似操作。
[root@servera ~]# lvcreate -V 2G -T vg_bricks/thinpool -n brick-a1
Logical volume "brick-a1" created.
[root@servera ~]# lvdisplay
--- Logical volume ---
LV Name thinpool
VG Name vg_bricks
LV UUID PPqAH3-EvW7-vtUn-OLI1-OB3v-mtBC-xouLUK
LV Write Access read/write
LV Creation host, time servera.lab.example.com, 2019-01-21 11:53:05 +0800
LV Pool metadata thinpool_tmeta
LV Pool data thinpool_tdata
LV Status available
# open 2
LV Size 10.00 GiB
Allocated pool data 0.10%
Allocated metadata 0.65%
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:2
--- Logical volume ---
LV Path /dev/vg_bricks/brick-a1
LV Name brick-a1
VG Name vg_bricks
LV UUID 5iZU2r-n2HU-ptgd-2oDK-3Pzs-xFpV-u5qmDa
LV Write Access read/write
LV Creation host, time servera.lab.example.com, 2019-01-21 13:28:11 +0800
LV Pool name thinpool
LV Status available
# open 1
LV Size 2.00 GiB
Mapped size 0.52%
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:4
[root@serverb ~]# lvcreate -V 2G -T vg_bricks/thinpool -n brick-b1
Logical volume "brick-b1" created.
[root@serverb ~]# lvdisplay
--- Logical volume ---
LV Name thinpool
VG Name vg_bricks
LV UUID dZYpaz-Kril-KzM6-pCYQ-83qG-T92s-aH1Sp0
LV Write Access read/write
LV Creation host, time serverb.lab.example.com, 2019-01-21 11:54:02 +0800
LV Pool metadata thinpool_tmeta
LV Pool data thinpool_tdata
LV Status available
# open 2
LV Size 10.00 GiB
Allocated pool data 0.10%
Allocated metadata 0.65%
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:2
--- Logical volume ---
LV Path /dev/vg_bricks/brick-b1
LV Name brick-b1
VG Name vg_bricks
LV UUID 0l2fLm-Xcr0-0J1y-Z9wh-X3Wn-N3pe-fe0y1K
LV Write Access read/write
LV Creation host, time serverb.lab.example.com, 2019-01-21 13:28:41 +0800
LV Pool name thinpool
LV Status available
# open 1
LV Size 2.00 GiB
Mapped size 0.52%
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:4
3.格式化逻辑卷
在servera上,mkfs -t xfs -i size=512 /dev/vg_bricks/brick-a1将brick-a1中的512M格式化为xfs格式。serverb类似操作。
[root@servera ~]# mkfs -t 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 -t 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.为逻辑卷创建挂载
在servera上, mkdir -p /bricks/brick-a1创建挂载目录,vim /etc/fstab编辑挂载配置文件, tail -1 /etc/fstab查看增加的内容,mount -a进行挂载,mount | grep brick确认挂载的内容。serverb类似操作。
[root@servera ~]# mkdir -p /bricks/brick-a1
[root@servera ~]# vim /etc/fstab
[root@servera ~]# tail -1 /etc/fstab
/dev/vg_bricks/brick-a1 /bricks/brick-a1 xfs defaults 1 2
[root@servera ~]# mount -a
[root@servera ~]# mount | grep brick
/dev/mapper/vg_bricks-brick--a1 on /bricks/brick-a1 type xfs (rw,relatime,seclabel,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota)
[root@serverb ~]# mkdir -p /bricks/brick-b1
[root@serverb ~]# vim /etc/fstab
[root@serverb ~]# tail -1 /etc/fstab
/dev/vg_bricks/brick-b1 /bricks/brick-b1 xfs defaults 1 2
[root@serverb ~]# mount -a
[root@serverb ~]# mount | grep brick
/dev/mapper/vg_bricks-brick--b1 on /bricks/brick-b1 type xfs (rw,relatime,seclabel,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota)
5.brick目录
在servera上,mkdir /bricks/brick-a1/brick创建目录。serverb类似操作。
[root@servera ~]# mkdir /bricks/brick-a1/brick
[root@serverb ~]# mkdir /bricks/brick-b1/brick
6.设置安全上下文
在servera上,semanage fcontext -a -t glusterd_brick_t /bricks/brick-a1/brick设置brick目录的安全上下文,restorecon -Rv /bricks重新递归载入/bricks目录安全上下文。serverb类似操作。
[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.任务测评
在workstation上,lab setup-bricks grade进行测评。主要是测评安全池是否创建,大小是否正确,文件是否挂载,格式是否正确,安全上下文是否设置正确。对servera和serverb两个节点都要进行测试。
[student@workstation ~]$ lab setup-bricks grade
Grading the student's work:
· Testing for thinly provisioned pool on servera.............. PASS
· Testing for thinly provisioned pool size on servera......... PASS
· Testing for mounted file system and type on servera......... PASS
· Testing for brick SELinux context on servera................ PASS
· Testing for thinly provisioned pool on serverb.............. PASS
· Testing for thinly provisioned pool size on serverb......... PASS
· Testing for mounted file system and type on serverb......... PASS
· Testing for brick SELinux context on serverb................ PASS
Overall lab grade.............................................. PASS