LVM管理

===================================
创建LVM
VG扩展 / 缩小
LV扩容

文件系统扩容

基本分区( MBR | GPT )-------> Filesustem ---------> mount
逻辑卷LVM -------->Filesustem ---------> mount
( 容错交给raid )
PE:Physical extent 物理扩展 4M 8M 16M 32M 64M 创建VG时指定 -s 8M
LE:Logical extent 逻辑扩展

LVM管理
一、创建LVM
0.准备物理磁盘
可以是 /dev/sdb /dev/sdc1
1.pvcreate、pvs、pvscan、pvdisplay、pvremove
vgcreate....
lvcreate......
pvcreate /dev/sdc
vgcreate datavg /dev/sdc
//创建逻辑卷
创建一个指定大小(100M)的lv,并指定名字为lv1 lv2
lvcreate -L 100M -n lv1 datavg
lvcreate -l 25 -n lv2 datavg //PE默认为4M,增加25个PE
2.创建文件系统并挂载
[root@ecs-test-1 ~]# mkfs.ext4 /dev/datavg/lv1
[root@ecs-test-1 ~]# mkfs.xfs /dev/datavg/lv2
[root@ecs-test-1 ~]# vim /etc/fstab
/dev/datavg/lv1 /mnt/lv1 ext4 defaults 0 0
/dev/datavg/lv2 /mnt/lv2 xfs defaults 0 0
[root@ecs-test-1 ~]# mount -a
[root@ecs-test-1 ~]# df -h
在线扩容 online
二、VG管理
1.扩大VG
[root@localhost ~]# vgextend datavg /dev/sdd
Physical volume "/dev/sdd" successfully created.
Volume group "datavg" successfully extended
正常流程应该是先将dev/sdd pvcreate 然后 vgextend 扩大
2.缩小VG
先做数据的迁移
vgreduce datavg /dev/sde //将无数据的硬盘移除
Removed "/dev/sde" from volume group "datavg"
pvmove /dev/sdc //先将数据迁移再移除硬盘
/dev/sdc: Moved: 30.00%
/dev/sdc: Moved: 50.00%
/dev/sdc: Moved: 100.00%
vgreduce datavg /dev/sdc
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <19.00g 0
/dev/sdc lvm2 --- 1.00g 1.00g
/dev/sdd datavg lvm2 a-- 1020.00m 820.00m
/dev/sde lvm2 --- 1.00g 1.00g
三、LV扩容(两个步骤,先进行lv扩容,在进行fs扩容)
1.lv扩容
[root@localhost ~]# lvextend -L +201M /dev/datavg/lv1
Rounding size to boundary between physical extents: 204.00 MiB. //默认一个扩展为4M,正常;总共有76个扩展
Size of logical volume datavg/lv1 changed from 100.00 MiB (25 extents) to 304.00 MiB (76 extents).
Logical volume datavg/lv1 successfully resized.
[root@localhost ~]# lvextend -L 201M /dev/datavg/lv2
Rounding size to boundary between physical extents: 204.00 MiB.
Size of logical volume datavg/lv2 changed from 100.00 MiB (25 extents) to 204.00 MiB (51 extents).
Logical volume datavg/lv2 successfully resized.
+50% FREE
[root@localhost ~]# lvscan
ACTIVE '/dev/datavg/lv1' [304.00 MiB] inherit
ACTIVE '/dev/datavg/lv2' [204.00 MiB] inherit
2.FS扩容
a.xfs
xfs_growfs /dev/datavg/lv2 //后面没有参数默认扩展到最大
b.ext2/3/4
resize2fs /dev/datavg/lv1 //后面没有参数默认扩展到最大
数据迁移:

  1. 把storage B 加入到 VG
  2. pvmove 将storage A 数据迁移到 B
  3. vgreduce 将 storage A 移除
    LVM管理
上一篇:R1-010 Linux重定向小结


下一篇:Struts-config.xml配置文件《action-mappings》元素的详解