lvm邏輯卷管理

1.分區node

*4個分區,每一個1.5G左右,systemid爲8eapp

*所有的分區整合成一個VG,PE大小爲16Mide

*最初所有的VG容量都給LVspa

*最終LV格式化爲ext4文件系統,掛載在/mnt/LVM3d

[root@server3 ~]# fdisk -lorm

 

sk /dev/vdc: 10.7 GB, 10737418240 bytes, 20971520 sectorsserver

Units = sectors of 1 * 512 = 512 bytesip

Sector size (logical/physical): 512 bytes / 512 bytesrem

I/O size (minimum/optimal): 512 bytes / 512 bytesit

Disk label type: dos

Disk identifier: 0xa859763d

 

   Device Boot      Start         End      Blocks   Id  System

/dev/vdc1            2048     2099199     1048576   8e  Linux LVM

/dev/vdc2         2099200     4196351     1048576   8e  Linux LVM

/dev/vdc3         4196352     6293503     1048576   8e  Linux LVM

/dev/vdc4         6293504    20971519     7339008    5  Extended

/dev/vdc5         6295552     8392703     1048576   8e  Linux LVM

 

2.pv

pv相關命令:

pvcreate:將物理分區新建成爲PV

pvscan:查詢目前系統裏面任何具備PV的磁盤

pvdisplay:顯示出目前系統上面的PV狀態

pvremove:將PV屬性刪除,讓該分區不具備PV屬性

 

ot@server3 ~]# pvcreate /dev/vdc1

  Physical volume "/dev/vdc1" successfully created.

[root@server3 ~]# pvcreate /dev/vdc2

  Physical volume "/dev/vdc2" successfully created.

[root@server3 ~]# pvcreate /dev/vdc3

  Physical volume "/dev/vdc3" successfully created.

[root@server3 ~]# pvcreate /dev/vdc5

  Physical volume "/dev/vdc5" successfully created.

 

[root@server3 ~]# pvscan

  PV /dev/vdc2                      lvm2 [1.00 GiB]

  PV /dev/vdc1                      lvm2 [1.00 GiB]

  PV /dev/vdc5                      lvm2 [1.00 GiB]

  PV /dev/vdc3                      lvm2 [1.00 GiB]

  Total: 4 [4.00 GiB] / in use: 0 [0   ] / in no VG: 4 [4.00 GiB]

 

[root@server3 ~]# pvdisplay

  "/dev/vdc2" is a new physical volume of "1.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/vdc2

  VG Name              

  PV Size               1.00 GiB

  Allocatable           NO

  PE Size               0  

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               Ie4M3o-km18-qEfx-ZRzX-yy92-oAnA-Jcy82s

  

  "/dev/vdc1" is a new physical volume of "1.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/vdc1

  VG Name              

  PV Size               1.00 GiB

  Allocatable           NO

  PE Size               0  

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               dOedne-APJi-U06R-8iOH-QmDo-izbc-31bhai

  

  "/dev/vdc5" is a new physical volume of "1.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/vdc5

  VG Name              

  PV Size               1.00 GiB

  Allocatable           NO

  PE Size               0  

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               vdprDc-3htE-qNxS-NDdm-9UJ1-UD3g-PX5fhF

  

  "/dev/vdc3" is a new physical volume of "1.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/vdc3

  VG Name              

  PV Size               1.00 GiB

  Allocatable           NO

  PE Size               0  

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               ld45eP-Bmy5-pXUK-66eb-DsDu-5iSF-hjh6hQ

 

3.VG

相關命令介紹

vgcreate:新建vg的命令

vgscan:查看系統上是否有vg的存在

vgdisplay:顯示目前系統上vg狀態

vgextend:在vg內增長額外的pv

vgreduce:在vg內刪除pv

vgchange:設置vg是否啓動

vgremove:刪除一個vg

               [後根pe大小] [大小] [vg名稱]

[root@server3 ~]# vgcreate      -s       16M     vgn    /dev/vdc{1,2,3}

  Volume group "vgn" successfully created

[root@server3 ~]# vgscan

  Reading volume groups from cache.

  Found volume group "vgn" using metadata type lvm2

[root@server3 ~]# pvscan

  PV /dev/vdc1   VG vgn             lvm2 [1008.00 MiB / 1008.00 MiB free]

  PV /dev/vdc2   VG vgn             lvm2 [1008.00 MiB / 1008.00 MiB free]

  PV /dev/vdc3   VG vgn             lvm2 [1008.00 MiB / 1008.00 MiB free]

  PV /dev/vdc5                      lvm2 [1.00 GiB]

  Total: 4 [3.95 GiB] / in use: 3 [2.95 GiB] / in no VG: 1 [1.00 GiB]

 

[root@server3 ~]# vgdisplay

  --- Volume group ---

  VG Name               vgn

  System ID            

  Format                lvm2

  Metadata Areas        3

  Metadata Sequence No  1

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                0

  Open LV               0

  Max PV                0

  Cur PV                3

  Act PV                3

  VG Size               2.95 GiB

  PE Size               16.00 MiB

  Total PE              189

  Alloc PE / Size       0 / 0  

  Free  PE / Size       189 / 2.95 GiB

  VG UUID               JjHOlH-RdcV-71dR-4wmK-NQ3N-pnRS-1y5dIV

 

上面咱們只用了三個PV,將剩下的/dev/vdc5也交給vgn

 

[root@server3 ~]# vgextend vgn /dev/vdc5

  Volume group "vgn" successfully extended

[root@server3 ~]# vgdisplay

  --- Volume group ---

  VG Name               vgn

  System ID            

  Format                lvm2

  Metadata Areas        4

  Metadata Sequence No  2

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                0

  Open LV               0

  Max PV                0

  Cur PV                4

  Act PV                4

  VG Size               3.94 GiB

  PE Size               16.00 MiB

  Total PE              252

  Alloc PE / Size       0 / 0  

  Free  PE / Size       252 / 3.94 GiB

  VG UUID               JjHOlH-RdcV-71dR-4wmK-NQ3N-pnRS-1y5dIV

 

4.lv

相關命令:

lvcreate:新建lv

lvscan:查詢系統上面的lv

lvdisplay:顯示系統上面的lv狀態

lvextend:在lv裏面增長容量

lvreduce:在lv裏面減小容量

lvremove:刪除一個lv

lvresize:對LV進行容量大小的調整

 

用法:lvcreate [-L N[mgt]] [-n LV名稱] VG名稱

      lvcreate [-l N] [-n LV名稱] VG名稱

-L:後面跟容量,最小單位爲pe,因此容量最好是pe的倍數

-l:後面能夠跟pe的個數,而不是數量

-n:後面接的時LV的名稱

 

[root@server3 ~]# lvcreate -l 252 -n lvn vgn

  Logical volume "lvn" created.

[root@server3 ~]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/vgn/lvn

  LV Name                lvn

  VG Name                vgn

  LV UUID                3cZBXM-Ef2z-wDLR-Fyxx-TmzD-Payq-BJ6eTm

  LV Write Access        read/write

  LV Creation host, time server3, 2019-01-21 20:32:58 +0800

  LV Status              available

  # open                 0

  LV Size                3.94 GiB

  Current LE             252

  Segments               4

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     8192

  Block device           252:0

 

 

5.文件系統掛載

[root@server3 ~]# mkfs.ext4 /dev/vgn/lvn

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

258048 inodes, 1032192 blocks

51609 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1056964608

32 block groups

32768 blocks per group, 32768 fragments per group

8064 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@server3 mnt]# mount /dev/vgn/lvn  /mnt/lvm/

/dev/mapper/vgn-lvn   3998400   16120   3759460   1% /mnt/lvm

相關文章
相關標籤/搜索