逻辑卷条带化

LVM条带模式:交错存储数据,数据均匀地分布在VG的指定磁盘中,对于I/O密集的应用有良好的效果。

1.优点:

(1)条带化后可以均匀分配II/O压力,从而改善磁盘性能
(2)避免单一磁盘的热点问题
(3)可以是数据分布均匀

2.添加4块磁盘

[root@localhost ~]# lsblk
sdb 8:16 0 1G 0 disk
sdc 8:32 0 2G 0 disk
sdd 8:48 0 3G 0 disk
sde 8:64 0 4G 0 disk

3.创建pv

[root@localhost ~]# pvcreate /dev/sd{b..e}
Physical volume "/dev/sdb" successfully created.
Physical volume "/dev/sdc" successfully created.
Physical volume "/dev/sdd" successfully created.
Physical volume "/dev/sde" successfully created.

4.创建vg

[root@localhost ~]# vgcreate datavg /dev/sd{b..e}
Volume group "datavg" successfully created

5.创建lv,由于有4个pv设备,所以定义4个条块,也就是说数据在写进逻辑卷时,需要条块化分散到4个pv中。

[root@localhost ~]# lvcreate -L 2G -n lv_data1 -i4 datavg
Using default stripesize 64.00 KiB.
Logical volume "lv_data1" created.

6.查看条带卷信息

[root@localhost ~]# lvdisplay -m
……..
--- Logical volume ---
LV Path /dev/datavg/lv_data1
LV Name lv_data1
VG Name datavg
LV UUID g5gVhI-u0cO-BwOK-7OfU-Jg0w-Gl0B-24KPz7
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2021-04-23 15:34:46 +0800
LV Status available
# open 0
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 1024
    Block device 253:7
    --- Segments ---
    Logical extents 0 to 511:
    Type striped
    Stripes 4 //分布设备
    Stripe size 64.00 KiB //默认条块大小
    Stripe 0:
    Physical volume /dev/sdb
    Physical extents 0 to 127
    Stripe 1:
    Physical volume /dev/sdc
    Physical extents 0 to 127
    Stripe 2:
    Physical volume /dev/sdd
    Physical extents 0 to 127
    Stripe 3:
    Physical volume /dev/sde
    Physical extents 0 to 127

7.再次创建lv,条块大小为128KB,分布在3个pv中

[root@localhost ~]# lvcreate -L 1G -i3 -I 128 -n lv_data2 datavg /dev/sdb /dev/sdc /dev/sdd
Rounding size 1.00 GiB (256 extents) up to stripe boundary size <1.01 GiB(258 extents).
Logical volume "lv_data2" created.

8.查看条带卷信息

[root@localhost ~]# lvdisplay -m
…………….
--- Logical volume ---
LV Path /dev/datavg/lv_data1
LV Name lv_data1
VG Name datavg
LV UUID g5gVhI-u0cO-BwOK-7OfU-Jg0w-Gl0B-24KPz7
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2021-04-23 15:34:46 +0800
LV Status available
# open 0
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 1024
    Block device 253:7

--- Segments ---
Logical extents 0 to 511:
Type striped
Stripes 4
Stripe size 64.00 KiB
Stripe 0:
Physical volume /dev/sdb
Physical extents 0 to 127
Stripe 1:
Physical volume /dev/sdc
Physical extents 0 to 127
Stripe 2:
Physical volume /dev/sdd
Physical extents 0 to 127
Stripe 3:
Physical volume /dev/sde
Physical extents 0 to 127
--- Logical volume ---
LV Path /dev/datavg/lv_data2
LV Name lv_data2
VG Name datavg
LV UUID 9LDa2t-u4mi-m8Uv-KZtD-82hl-MUxY-GX6BPy
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2021-04-23 15:41:24 +0800
LV Status available
# open 0
LV Size <1.01 GiB
Current LE 258
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 1536
    Block device 253:8

--- Segments ---
Logical extents 0 to 257:
Type striped
Stripes 3
Stripe size 128.00 KiB
Stripe 0:
Physical volume /dev/sdb
Physical extents 128 to 213
Stripe 1:
Physical volume /dev/sdc
Physical extents 128 to 213
Stripe 2:
Physical volume /dev/sdd
Physical extents 128 to 213

9.由于条块做了映射,所以用dmsetup来进行启用。

[root@localhost ~]# dmsetup deps /dev/datavg/lv_data{1,2}
/dev/datavg/lv_data1: 4 dependencies : (8, 64) (8, 48) (8, 32) (8, 16)
/dev/datavg/lv_data2: 3 dependencies : (8, 48) (8, 32) (8, 16)

10.挂载测试

[root@localhost ~]# mkdir data{1,2}
[root@localhost ~]# mkfs.xfs /dev/datavg/lv_data
lv_data1 lv_data2
[root@localhost ~]# mkfs.xfs /dev/datavg/lv_data1
[root@localhost ~]# mkfs.xfs /dev/datavg/lv_data2
[root@localhost ~]# mount /dev/datavg/lv_data1 data1
[root@localhost ~]# mount /dev/datavg/lv_data2 data2

11.测试

# dd if=/dev/zero of=/root/data1/1 bs=1M count=1024
# iostat 1
avg-cpu: %user %nice %system %iowait %steal %idle
0.00 0.00 96.10 0.00 0.00 3.90

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 0.00 0.00 0.00 0 0
sdb 2044.16 0.65 138368.83 0 106544
sdc 2049.35 11.69 138327.27 9 106512
sdd 2040.26 0.00 138306.49 0 106496
sde 2048.05 11.69 138223.38 9 106432
可以看到4块磁盘均有数据同时写入

# dd if=/dev/zero of=/root/data2/2 bs=1M count=1024
# iostat 1
avg-cpu: %user %nice %system %iowait %steal %idle
1.04 0.00 47.92 1.04 0.00 50.00

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 3.12 33.33 0.00 32 0
dm-0 3.12 33.33 0.00 32 0
dm-1 0.00 0.00 0.00 0 0
dm-2 0.00 0.00 0.00 0 0
dm-3 0.00 0.00 0.00 0 0
dm-4 0.00 0.00 0.00 0 0
dm-5 0.00 0.00 0.00 0 0
dm-6 0.00 0.00 0.00 0 0
sdb 1129.17 9.38 144000.00 9 138240
sdc 1126.04 0.00 144133.33 0 138368
sdd 1132.29 18.23 144000.00 17 138240
sde 0.00 0.00 0.00 0 0
dm-7 0.00 0.00 0.00 0 0
dm-8 3386.46 27.60 432000.00 26 414720
可以看到3块磁盘均有数据同时写入

你可能感兴趣的:(逻辑卷条带化)