卷组、条带化

手动再添加两块硬盘(SCSI类型),容量均为8G,分别将两块硬盘设置为一个主分区(2G容量)和两个逻辑分区(分别2G容量),并完成PV物理卷的初始化操作;

[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0  500M  0 part /boot
└─sda2            8:2    0 19.5G  0 part 
  ├─centos-root 253:0    0 17.5G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0    8G  0 disk 
sdc               8:32   0    8G  0 disk 
sr0              11:0    1    4G  0 rom  /run/media/root/CentOS 7 x86_64

#磁盘分区
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x21d517a7.

Command (m for help): n								#添加新分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-16777215, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): +2G
Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e
Partition number (2-4, default 2): 
First sector (4196352-16777215, default 4196352): 
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-16777215, default 16777215):  
Using default value 16777215
Partition 2 of type Extended and of size 6 GiB is set

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (4198400-16777215, default 4198400): 
Using default value 4198400
Last sector, +sectors or +size{K,M,G} (4198400-16777215, default 16777215): +2G
Partition 5 of type Linux and of size 2 GiB is set

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l
Adding logical partition 6
First sector (8394752-16777215, default 8394752): 
Using default value 8394752
Last sector, +sectors or +size{K,M,G} (8394752-16777215, default 16777215): +2G
Partition 6 of type Linux and of size 2 GiB is set
Command (m for help): w
#冗余操作不再描述
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0  500M  0 part /boot
└─sda2            8:2    0 19.5G  0 part 
  ├─centos-root 253:0    0 17.5G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0    8G  0 disk 
├─sdb1            8:17   0    2G  0 part 
├─sdb2            8:18   0    1K  0 part 
├─sdb5            8:21   0    2G  0 part 
└─sdb6            8:22   0    2G  0 part 
sdc               8:32   0    8G  0 disk 
├─sdc1            8:33   0    2G  0 part 
├─sdc2            8:34   0    1K  0 part 
├─sdc5            8:37   0    2G  0 part 
└─sdc6            8:38   0    2G  0 part 
sr0              11:0    1    4G  0 rom  /run/media/root/CentOS 7 x86_64
[root@localhost ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
[root@localhost ~]# pvcreate /dev/sdb5
  Physical volume "/dev/sdb5" successfully created
[root@localhost ~]# pvcreate /dev/sdb6
  Physical volume "/dev/sdb6" successfully created
[root@localhost ~]# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created
[root@localhost ~]# pvcreate /dev/sdc5
  Physical volume "/dev/sdc5" successfully created
[root@localhost ~]# pvcreate /dev/sdc6
  Physical volume "/dev/sdc6" successfully created

将/dev/sdb1及/dev/sdc5加入到卷组VG1中,其显示的逻辑卷名称为LV1,格式化为ext3文件系统,对应挂载目录为/volume,并针对/volume目录实现开机自动挂载;

[root@localhost ~]# vgcreate VG1 /dev/sdb1 /dev/sdc5
  Volume group "VG1" successfully created
[root@localhost ~]# lvcreate -L 3.99G -n LV1 VG1
  Rounding up size to full physical extent 3.99 GiB
  Logical volume "LV1" created.
[root@localhost ~]# mkfs.ext3 /dev/VG1/LV1 
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
261632 inodes, 1046528 blocks
52326 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

[root@localhost ~]# mkdir /volume
[root@localhost ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Oct 29 17:30:58 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=de750585-8461-4264-a9f8-e5a6d13bc733 /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
/dev/VG1/LV1      /volume                       ext3    defaults        0 0

@localhost ~]# mount -a
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0  500M  0 part /boot
└─sda2            8:2    0 19.5G  0 part 
  ├─centos-root 253:0    0 17.5G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0    8G  0 disk 
├─sdb1            8:17   0    2G  0 part 
│ └─VG1-LV1     253:2    0    4G  0 lvm  /volume

针对现有的逻辑卷/dev/vg1/lv1实现在线扩容,将/dev/sdb5分区加入到已有的逻辑卷LV1中,实现目录/volume在线扩容2G容量,总容量达到6G;

[root@localhost ~]# vgextend VG1 /dev/sdb5
  Volume group "VG1" successfully extended
[root@localhost ~]# lvextend -L +1.99G /dev/VG1/LV1 
  Rounding size to boundary between physical extents: 1.99 GiB
  Size of logical volume VG1/LV1 changed from 3.99 GiB (1022 extents) to 5.98 GiB (1532 extents).
  Logical volume LV1 successfully resized.
oot@localhost ~]# lvs
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  LV1  VG1    -wi-ao----  5.98g                                                    
  root centos -wi-ao---- 17.47g                                                    
  swap centos -wi-ao----  2.00g 

利用分区/dev/sdb6及/dev/sdc1完成条带卷的设置,条带容量为8KB,建立的条带卷容量为2G,卷组名称VG1,条带卷名称为stripe1;

[root@localhost ~]# vgextend VG1 /dev/sdb6 /dev/sdc1
  Volume group "VG1" successfully extended
[root@localhost ~]# lvcreate -n stripe1 -L 1.99G -i 2 -I 8 VG1 /dev/sdb6 /dev/sdc1
  Rounding up size to full physical extent 1.99 GiB
  Logical volume "stripe1" created.
root@localhost ~]# lvs
  LV      VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  LV1     VG1    -wi-ao----  5.98g                                                    
  stripe1 VG1    -wi-a-----  1.99g  
  [root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/VG1/stripe1
  LV Name                stripe1
  VG Name                VG1
  LV UUID                Tf6b2X-z9FH-KO7O-lXkS-Lr43-cRA2-gEUAxd
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2021-11-02 11:32:02 -0100
  LV Status              available
  # open                 0
  LV Size                1.99 GiB
  Current LE             510
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:3

利用分区/dev/sdc6完成条带卷的设置,条带容量为64KB,建立的条带卷容量为3G,卷组名称VG1,条带卷名称为stripe2;

[root@localhost ~]# vgextend VG1 /dev/sdc6
  Volume group "VG1" successfully extended
[root@localhost ~]# lvcreate -n stripe2 -L 1.99G -i 1 -I 64 VG1 /dev/sdc6
  Ignoring stripesize argument with single stripe.
  Rounding up size to full physical extent 1.99 GiB
  Logical volume "stripe2" created.
  [root@localhost ~]# lvdisplay  
  --- Logical volume ---
  LV Path                /dev/VG1/stripe2
  LV Name                stripe2
  VG Name                VG1
  LV UUID                uy8sUR-8O1Z-8ln3-umnp-2yIT-Ak2H-Uo0UwY
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2021-11-02 11:37:10 -0100
  LV Status              available
  # open                 0
  LV Size                1.99 GiB
  Current LE             510
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:4

借助命令hdparm完成磁盘读写速度的测试,

[root@localhost ~]# yum -y install hdparm.x86_64 
[root@localhost ~]# hdparm -t /dev/VG1/stripe1

/dev/VG1/stripe1:
 Timing buffered disk reads: 2040 MB in  0.95 seconds = 2146.13 MB/sec
[root@localhost ~]# hdparm -t /dev/VG1/stripe2

/dev/VG1/stripe2:
 Timing buffered disk reads: 2040 MB in  0.63 seconds = 3213.29 MB/sec

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值