Lvm advanced topics

3,232 views
3,025 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,232
On SlideShare
0
From Embeds
0
Number of Embeds
117
Actions
Shares
0
Downloads
112
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Lvm advanced topics

  1. 1. LVM Advanced Topics Will SterlingLinux & UNIX Consultant @ PARSEC Group
  2. 2. Agenda● Logical Volume Manager Overview● Data Protection● Data migration● LVM & Multipath Devices● Using LVM in a Rescue environment LVM Advanced topics
  3. 3. LVM Overview● Eliminates the need for partitions to manage disks● Adds flexibility that partitions do not provide● Provides RAID 0 and RAID 1 like functionality● Logical Volumes can be created small and grown as needed much easier then a partition● As useful on a laptop with one hard drive as it is on servers with hundreds of LUNs LVM Advanced topics
  4. 4. LVM Layout LVM Advanced topics
  5. 5. LVM Userlandpvchange vgcfgbackup lvchangepvck vgcfgrestore lvconvertpvcreate vgchange lvcreatepvdisplay vgck lvdisplaypvmove vgconvert lvextendpvremove vgcreate lvreducepvresize vgdisplay lvremovepvs vgexport lvrenamepvscan vgextend lvresize vgimport lvs vgimportclone lvscan vgmerge vgmknodes vgreduce vgremove vgrename vgs vgscan vgsplit LVM Advanced topics
  6. 6. Data Protection with LVM● Data is protected via LE mirroring.● Mirrored logical volumes can span more thentwo storage devices in a RAID 0 + 1 like fashion.● Does not provide parity data protection and cannot be used to create RAID 3 - 6 logical volumes. LVM Advanced topics
  7. 7. Building A Mirrored Logical Volume[wills@localhost ~]$ sudo pvcreate /dev/vdb Physical volume "/dev/vdb" successfully created[wills@localhost ~]$ sudo pvcreate /dev/vdc Physical volume "/dev/vdc" successfully created[wills@localhost ~]$ sudo vgcreate VolGroup02 /dev/vdb  /dev/vdc Volume group "VolGroup02" successfully created[wills@localhost ~]$ sudo lvcreate ­m1 ­L 508M ­­corelog ­­nosync ­n LogVol00 VolGroup02 WARNING: New mirror wont be synchronised. Dont read what you didnt write! Logical volume "LogVol00" created LVM Advanced topics
  8. 8. Building A Mirrored Logical Volume Continued[wills@localhost ~]$ sudo lvdisplay /dev/VolGroup02/LogVol00­­­ Logical volume ­­­LV Name /dev/VolGroup02/LogVol00VG Name VolGroup02LV UUID S7PeP1­QN2Y­VtxF­0qjY­zk7j­cq6n­8rJjvFLV Write Access read/writeLV Status available# open 0LV Size 508.00 MiBCurrent LE 127Mirrored volumes 2Segments 1Allocation inheritRead ahead sectors auto­ currently set to 256Block device 253:2 LVM Advanced topics
  9. 9. Recover Failed Drive Mirrored LV[wills@localhost ~]$ sudo lvdisplay ­v /dev/VolGroup02/LogVol00Using logical volume(s) on command lineWiping cache of LVM­capable devicesCouldnt find device with uuid pKWuz6­XidZ­aqAS­6GQG­9OrB­cyQW­zOnRgp.There are 1 physical volumes missing.­­­ Logical volume ­­­LV Name /dev/VolGroup02/LogVol00VG Name VolGroup02LV UUID Dtrdmh­qT5M­xjtN­mD0t­mcM2­j3I7­CCBJUALV Write Access read/writeLV Status available­­­ Snip ­­­ LVM Advanced topics
  10. 10. Recover Failed Drive Mirrored LV Continued[wills@localhost ~]$ sudo pvcreate ­­uuid pKWuz6­XidZ­aqAS­6GQG­9OrB­cyQW­zOnRgp ­­restorefile /etc/lvm/archive/VolGroup02_00037.vg /dev/vdeCouldnt find device with uuid pKWuz6­XidZ­aqAS­6GQG­9OrB­cyQW­zOnRgp.Physical volume "/dev/vde" successfully created[wills@localhost ~]$ sudo vgcfgrestore ­f /etc/lvm/archive/VolGroup02_00037.vgVolGroup02 Restored volume group VolGroup02[wills@localhost ~]$ sudo vgchange ­a y VolGroup021 logical volume(s) in volume group "VolGroup02" now active LVM Advanced topics
  11. 11. Building A Stripped & Mirrored Logical[wills@localhost ~]$ sudo pvcreate /dev/vdbPhysical volume "/dev/vdb" successfully created[wills@localhost ~]$ sudo pvcreate /dev/vddPhysical volume "/dev/vdd" successfully created[wills@localhost ~]$ sudo pvcreate /dev/vdcPhysical volume "/dev/vdc" successfully created[wills@localhost ~]$ sudo pvcreate /dev/vdfPhysical volume "/dev/vdf" successfully created[wills@localhost ~]$ sudo vgcreate VolGroup02 /dev/vdb /dev/vdd /dev/vdf /dev/vdeVolume group "VolGroup02" successfully created[wills@localhost ~]$ sudo lvcreate ­i2 ­I128 ­m 1 ­­corelog ­L900M ­n LogVol00 VolGroup02Rounding size (225 extents) up to stripe boundary size (226 extents)Logical volume "LogVol00" created LVM Advanced topics
  12. 12. Data Migration[wills@localhost ~]$ sudo lvdisplay ­m /dev/mapper/VolGroup02­LogVol00­­­ Logical volume ­­­LV Name /dev/VolGroup02/LogVol00VG Name VolGroup02­­ SNIP ­­Current LE 226­­ SNIP ­­­­­ Segments ­­­Logical extent 0 to 225:Type striped Stripes 2 Stripe size 128.00 KiB Stripe 0: Physical volume /dev/vdb  Physical extents 0 to 112 Stripe 1: Physical volume /dev/vdd  Physical extents 0 to 112 LVM Advanced topics
  13. 13. Data Migration Continued[wills@localhost ~]$ sudo vgextend VolGroup02 /dev/vde /dev/vdfVolume group "VolGroup02" successfully extended[wills@localhost ~]$ sudo lvconvert ­m1 ­­corelog ­­stripes 2 ­I 128 /dev/VolGroup02/LogVol00VolGroup02/LogVol00: Converted: 0.0%VolGroup02/LogVol00: Converted: 31.0%VolGroup02/LogVol00: Converted: 69.5%VolGroup02/LogVol00: Converted: 100.0%[wills@localhost ~]$ sudo lvconvert ­m0 ­­corelog ­­stripes 2 ­I 128 /dev/VolGroup02/LogVol00 /dev/vdd /dev/vdbLogical volume LogVol00 converted. LVM Advanced topics
  14. 14. Data Migration Continued[wills@localhost ~]$ sudo lvdisplay ­m /dev/mapper/VolGroup02­LogVol00­­­ Logical volume ­­­LV Name /dev/VolGroup02/LogVol00VG Name VolGroup02­­ SNIP ­­­­­ Segments ­­­Logical extent 0 to 225: Type striped Stripes 2 Stripe size 128.00 KiB Stripe 0:  Physical volume /dev/vdf  Physical extents 0 to 112 Stripe 1:  Physical volume /dev/vde  Physical extents 0 to 112 LVM Advanced topics
  15. 15. Data Migration Continued[wills@localhost ~]$ sudo pvmove /dev/vdd /dev/vdb/dev/vdd: Moved: 0.0%/dev/vdd: Moved: 53.1%/dev/vdd: Moved: 100.0%/dev/vdb: Moved: 0.0%/dev/vdb: Moved: 53.1%/dev/vdb: Moved: 100.0%[wills@localhost ~]$ sudo lvdisplay ­m /dev/VolGroup02/LogVol00­­ SNIP ­­­­­ Segments ­­­Logical extent 0 to 225: Type striped Stripes 2 Stripe size 128.00 KiB Stripe 0:  Physical volume /dev/vdf  Physical extents 0 to 112 Stripe 1:  Physical volume /dev/vde  Physical extents 0 to 112 LVM Advanced topics
  16. 16. Data Migration Continued[wills@localhost ~]$ sudo vgreduce VolGroup02 /dev/vdbRemoved "/dev/vdb" from volume group "VolGroup02"[wills@localhost ~]$ sudo vgreduce VolGroup02 /dev/vddRemoved "/dev/vdd" from volume group "VolGroup02"[wills@localhost ~]$ sudo vgdisplay ­v VolGroup02­­ SNIP ­­­­­ Physical volumes ­­­PV Name/dev/vdePV UUIDTrCXyk­6pNR­HoZ1­JNM1­2jjO­MdBf­K8DMxdPV StatusallocatableTotal PE / Free PE 127 / 14PV Name/dev/vdfPV UUIDjno5H1­S7IA­J5yM­mDOK­QCGS­YMp9­8wnXNxPV StatusallocatableTotal PE / Free PE 127 / 14 LVM Advanced topics
  17. 17. LVM & Multipath Devices● LVM scans the attached drives for its logicalvolumes at boot and when any LVM command isrun.● LVM must be configured so that it only finds each PV once!● LVM will not start a Volume Group if it findsduplicate matches for a PV UUID.● Limits on LVMs ability to find duplicate paths areimplemented with a Filter in lvm.conffilter = [ "a/mpath.*/", "r/.*/" ] LVM Advanced topics
  18. 18. LVM in the Rescue Environment● The many commands that comprise the LVM userland are allsoftlinks to /sbin/lvm● Use the same commands you are used to using but prefix thecommand with "lvm "● You may need to locate and active VGs and LVs ○ lvm vgscan ○ lvm vgchange -a y● Any configuration settings that were needed in lvm.conf, i.e."filter", will need to be passed on the command line with --config. ○ lvm vgscan --config devices{ filter = [ "a/mpath.*/","r/.*/" ] } LVM Advanced topics
  19. 19. LVM in the Rescue Environment● LVM Administrator Guide: http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/index.html● LVM2 Project Wiki: http://sources.redhat.com/lvm2/wiki● LVM2 Mailing List: https://www.redhat.com/mailman/listinfo/linux-lvm● LVM2 Source Code:ftp://sources.redhat.com/pub/lvm2/● IRC Freenode #lvm● linux@parsec.com ! LVM Advanced topics

×