LVM创建实例讲解


LVM讲解:
图像大纲:

LVM创建实例讲解

1)LVM是什么,作用:
LVM称为逻辑卷管理,作用是提高磁盘分区的管理和使用灵活性。
通过逻辑卷LVM可以有效的管理和分配磁盘空间,可以把分散的小分区组合成一个大的卷组,从卷组中分出需要的空间做出逻辑卷,这样使得磁盘扩容和缩减方便易用。还有着备份的功能,指的就是lvm快照。
2)创建实例:
磁盘-》分区-》ID修改8e-》保存。
我用来一个磁盘通过分区来做的。还可以每个磁盘分一个区来做。
Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1        1306    10490413+  8e  Linux LVM
/dev/sdb2            1307        2612    10490445  8e  Linux LVM
/dev/sdb3            2613        3918    10490445  8e  Linux LVM

3)创建物理卷:通过pvcreate命令。
pvcreate /dev/sdb1
pvcreate /dev/sdb2
pvcreate /dev/sdb3
[root@station106 ~]# pvs(查看创建的物理卷)。
PV        VG  Fmt  Attr PSize  PFree
/dev/sda2  vg0  lvm2 a--  59.99g  7.99g
/dev/sdb1      lvm2 a--  10.00g 10.00g
/dev/sdb2      lvm2 a--  10.00g 10.00g
/dev/sdb3      lvm2 a--  10.00g 10.00g
pvdisplay 查看更加详细的内容。

 
[root@station106 ~]# pvdisplay
--- Physical volume ---
PV Name              /dev/sdb1
VG Name              myvg
PV Size              10.00 GiB / not usable 4.54 MiB
Allocatable          yes
PE Size              4.00 MiB
Total PE              2560
Free PE              2560
Allocated PE          0
PV UUID              XP8QfA-WQDd-1v9p-QKxk-AztZ-Nr9e-QbN6Gu
--- Physical volume ---
PV Name              /dev/sdb2
VG Name              myvg
PV Size              10.00 GiB / not usable 4.58 MiB
Allocatable          yes
PE Size              4.00 MiB
Total PE              2560
Free PE              2560
Allocated PE          0
PV UUID              f8Dtdd-fV9e-1yB7-1B8P-21mU-CU2f-fQDAxe
--- Physical volume ---
PV Name              /dev/sdb3
VG Name              myvg
PV Size              10.00 GiB / not usable 4.58 MiB
Allocatable          yes
PE Size              4.00 MiB
Total PE              2560
Free PE              2560
Allocated PE          0
PV UUID              rKNL0x-WXq2-gHYD-T27r-Gf05-a4y3-f4zqzt

4)创建逻辑卷:通过vgcreate。
 [root@station106 ~]# vgcreate myvg /dev/sdb{1,2,3}
  Volume group "myvg" successfully created

LVM创建实例讲解

[root@station106 ~]# vgs
VG  #PV #LV #SN Attr  VSize  VFree
myvg  3  0  0 wz--n- 30.00g 30.00g

5)创建逻辑卷,lvcreate。
[root@station106 ~]# lvcreate -L 10G -n test myvg
Logical volume "test" created
-L:空间大小。
-n:逻辑卷名称。
[root@station106 ~]# lvdisplay /dev/myvg/test
--- Logical volume ---
LV Path                /dev/myvg/test
LV Name                test
VG Name                myvg
LV UUID                wY1YUF-f0o6-jzu1-mtTL-64p0-qvfC-3QfF8y
LV Write Access        read/write
LV Creation host, time station106.magelinux.com, 2014-02-10 11:18:43 +0800
LV Status              available
# open                0
LV Size                10.00 GiB
Current LE            2560
Segments              1
Allocation            inherit
Read ahead sectors    auto
- currently set to    256
Block device          253:4

6)挂载使用创建好的逻辑卷。
mke2fs -t ext4 /dev/myvg/test 格式化。
mount /dev/myvg/test /mnt/挂载使用。

7)假如有一天逻辑卷不够用了。怎么从卷组扩展呢?如下分析。
逻辑卷扩展的大致步骤:
1,先确定扩展的大小,并确保所属的卷组有足够的剩余空间。
我现在要扩展5G,本身是10G的大小。命令如下:
[root@station106 ~]# lvextend -L +5G /dev/myvg/test
Extending logical volume test to 15.00 GiB
Logical volume test successfully resized

2,扩展物理边界。物理边界指的是本身的物理边缘大小。
[root@station106 ~]# lvdisplay /dev/myvg/test
--- Logical volume ---
LV Path                /dev/myvg/test
LV Name                test
VG Name                myvg
LV UUID                wY1YUF-f0o6-jzu1-mtTL-64p0-qvfC-3QfF8y
LV Write Access        read/write
LV Creation host, time station106.magelinux.com, 2014-02-10 11:18:43 +0800
LV Status              available
# open                1
LV Size                15.00 GiB
Current LE            3840
Segments              2
Allocation            inherit
Read ahead sectors    auto
- currently set to    256
Block device          253:4

当扩展完物理边界后你会发现,挂载中的逻辑卷还是本身的大小。
[root@station106 ~]# df -hT
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root
ext4    20G  387M  19G  3% /
tmpfs        tmpfs    242M    0  242M  0% /dev/shm
/dev/sda1    ext4    194M  29M  156M  16% /boot
/dev/mapper/vg0-usr
ext4    9.9G  1.9G  7.6G  20% /usr
/dev/mapper/vg0-var
ext4    20G  288M  19G  2% /var
/dev/mapper/myvg-test
ext4    9.9G  151M  9.2G  2% /mnt

扩展逻辑边界,逻辑边界指的是挂载后,在使用中的逻辑卷也直接识别了。
[root@station106 ~]# resize2fs /dev/myvg/test
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/myvg/test is mounted on /mnt; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/myvg/test to 3932160 (4k) blocks.
The filesystem on /dev/myvg/test is now 3932160 blocks long.
[root@station106 ~]# df -hT
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root
ext4    20G  387M  19G  3% /
tmpfs        tmpfs    242M    0  242M  0% /dev/shm
/dev/sda1    ext4    194M  29M  156M  16% /boot
/dev/mapper/vg0-usr
ext4    9.9G  1.9G  7.6G  20% /usr
/dev/mapper/vg0-var
ext4    20G  288M  19G  2% /var
/dev/mapper/myvg-test
ext4    15G  153M  14G  2% /mnt

上述就是扩展逻辑卷部分。

推荐阅读:

VMware上安装Oracle 10g RAC-ASM+裸设备

AIX上用裸设备安装Oracle

Oracle for AIX基于裸设备的表空间扩充步聚

  • 1
  • 2
  • 下一页

相关内容