Wise people learn when they can; fools learn when they must - Arthur Wellesley

Sunday, 2 April 2017

RHEL6-19-LOGICAL VOLUME MANAGER (LVM)-6


RHEL6-19-LOGICAL VOLUME MANAGER (LVM)-6


LVM OPERATIONS:

How to deactivate a VG?
How to activate a VG?
How to deactivate a LV?
How to activate a LV?
How to deactivate/activate a VG in cluster?
How to change the read/write permission of LV?
How to force a LV mirror for resync?


DEACTIVATE/ACTIVATE VG:

By default VG’s/LV’s are active after creation.

Sometimes it might be required to disable the VG for some testing or other purpose.

Command for this is

#vgchange –a (available) y (yes) or n (no) vgname


[root@rhel6-client1 ~]# df -kh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6              15G  6.3G  7.4G  46% /
tmpfs                 937M   76K  937M   1% /dev/shm
/dev/sda1             485M   37M  423M   8% /boot
/dev/sda3            1008M   34M  924M   4% /home
/dev/sda2             2.9G   69M  2.7G   3% /opt
/dev/mapper/vg02-testlv01Fvg02
                      291M   11M  266M   4% /testlv01Fvg02
/dev/mapper/vg02-testlv02Fvg02
                      388M   11M  358M   3% /testlv02Fvg02
/dev/mapper/vg01-lv01Fvg01
                      485M   11M  449M   3% /lv01Fvg01
/dev/mapper/vg01-lv02Fvg01
                      291M   11M  266M   4% /lv02Fvg01

[root@rhel6-client1 ~]# vgchange -a n vg01
  Can't deactivate volume group "vg01" with 2 open logical volume(s)

[root@rhel6-client1 ~]# umount /lv01Fvg01
[root@rhel6-client1 ~]# umount /lv02Fvg01

[root@rhel6-client1 ~]# vgchange -a n vg01
  0 logical volume(s) in volume group "vg01" now active

It means there is no active LV inside VG01.

[root@rhel6-client1 ~]# vgdisplay vg01
  --- Volume group ---
  VG Name               vg01
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1020.00 MiB
  PE Size               4.00 MiB
  Total PE              255
  Alloc PE / Size       200 / 800.00 MiB
  Free  PE / Size       55 / 220.00 MiB
  VG UUID               OK0vD5-GHIm-OQ6T-VyOX-vAtI-Dovk-asEiQ0

[root@rhel6-client1 ~]# lvdisplay /dev/vg01/lv01Fvg01
  --- Logical volume ---
  LV Path                /dev/vg01/lv01Fvg01
  LV Name                lv01Fvg01
  VG Name                vg01
  LV UUID                Qp3U0l-p3hB-3vgK-uV11-G9TI-KVz6-UszwZy
  LV Write Access        read/write
  LV Creation host, time rhel6-client1, 2017-04-01 14:56:18 +0530
  LV Status              NOT available ççç
  LV Size                500.00 MiB
  Current LE             125
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto

[root@rhel6-client1 ~]# lvdisplay /dev/vg01/lv02Fvg01
  --- Logical volume ---
  LV Path                /dev/vg01/lv02Fvg01
  LV Name                lv02Fvg01
  VG Name                vg01
  LV UUID                4FzNKe-ynpl-quer-z7oA-lZck-8aUV-3kDY0h
  LV Write Access        read/write
  LV Creation host, time rhel6-client1, 2017-04-01 14:56:32 +0530
  LV Status              NOT available ççç
  LV Size                300.00 MiB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto

[root@rhel6-client1 ~]# lvs
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv01Fvg01     vg01 -wi------ 500.00m
  lv02Fvg01     vg01 -wi------ 300.00m
  testlv01Fvg02 vg02 -wi-ao--- 300.00m
  testlv02Fvg02 vg02 -wi-ao--- 400.00m

w = write perm
i = inherited
a = active
o = open (device is open, volume is mounted/active)

There is no “ao” flag on vg01.

[root@rhel6-client1 ~]# vgchange -a y vg01
  2 logical volume(s) in volume group "vg01" now active

[root@rhel6-client1 ~]# lvs
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv01Fvg01     vg01 -wi-a---- 500.00m
  lv02Fvg01     vg01 -wi-a---- 300.00m
  testlv01Fvg02 vg02 -wi-ao--- 300.00m
  testlv02Fvg02 vg02 -wi-ao--- 400.00m

[root@rhel6-client1 ~]# mount /dev/vg01/lv01Fvg01 /lv01Fvg01
[root@rhel6-client1 ~]# mount /dev/vg01/lv02Fvg01 /lv02Fvg01

[root@rhel6-client1 ~]# lvs
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv01Fvg01     vg01 -wi-ao--- 500.00m
  lv02Fvg01     vg01 -wi-ao--- 300.00m
  testlv01Fvg02 vg02 -wi-ao--- 300.00m
  testlv02Fvg02 vg02 -wi-ao--- 400.00m

[root@rhel6-client1 ~]# lvdisplay /dev/vg01/lv01Fvg01
  --- Logical volume ---
  LV Path                /dev/vg01/lv01Fvg01
  LV Name                lv01Fvg01
  VG Name                vg01
  LV UUID                Qp3U0l-p3hB-3vgK-uV11-G9TI-KVz6-UszwZy
  LV Write Access        read/write
  LV Creation host, time rhel6-client1, 2017-04-01 14:56:18 +0530
  LV Status              available ççç
  # open                 1
  LV Size                500.00 MiB
  Current LE             125
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

[root@rhel6-client1 ~]# lvdisplay /dev/vg01/lv02Fvg01
  --- Logical volume ---
  LV Path                /dev/vg01/lv02Fvg01
  LV Name                lv02Fvg01
  VG Name                vg01
  LV UUID                4FzNKe-ynpl-quer-z7oA-lZck-8aUV-3kDY0h
  LV Write Access        read/write
  LV Creation host, time rhel6-client1, 2017-04-01 14:56:32 +0530
  LV Status              available ççç
  # open                 1
  LV Size                300.00 MiB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

DEACTIVATE/ACTIVATE LV:

(lvchange)

By default VG’s/LV’s are active after creation.

Sometimes it might be required to disable the LV for some testing or other purpose.


[root@rhel6-client1 ~]# lvchange -an /dev/vg01/lv02Fvg01
  Logical volume vg01/lv02Fvg01 contains a filesystem in use.

[root@rhel6-client1 ~]# umount /lv02Fvg01
[root@rhel6-client1 ~]# lvchange -an /dev/vg01/lv02Fvg01

[root@rhel6-client1 ~]# lvdisplay /dev/vg01/lv02Fvg01
  --- Logical volume ---
  LV Path                /dev/vg01/lv02Fvg01
  LV Name                lv02Fvg01
  VG Name                vg01
  LV UUID                4FzNKe-ynpl-quer-z7oA-lZck-8aUV-3kDY0h
  LV Write Access        read/write
  LV Creation host, time rhel6-client1, 2017-04-01 14:56:32 +0530
  LV Status              NOT available ççç
  LV Size                300.00 MiB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto

[root@rhel6-client1 ~]# lvs
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv01Fvg01     vg01 -wi-ao--- 500.00m
  lv02Fvg01     vg01 -wi------ 300.00m
  testlv01Fvg02 vg02 -wi-ao--- 300.00m
  testlv02Fvg02 vg02 -wi-ao--- 400.00m

[root@rhel6-client1 ~]# lvchange -ay /dev/vg01/lv02Fvg01

[root@rhel6-client1 ~]# lvs
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv01Fvg01     vg01 -wi-ao--- 500.00m
  lv02Fvg01     vg01 -wi-a---- 300.00m
  testlv01Fvg02 vg02 -wi-ao--- 300.00m
  testlv02Fvg02 vg02 -wi-ao--- 400.00m

[root@rhel6-client1 ~]# mount /dev/vg01/lv02Fvg01 /lv02Fvg01
[root@rhel6-client1 ~]# lvs
  LV            VG   Attr      LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv01Fvg01     vg01 -wi-ao--- 500.00m
  lv02Fvg01     vg01 -wi-ao--- 300.00m
  testlv01Fvg02 vg02 -wi-ao--- 300.00m
  testlv02Fvg02 vg02 -wi-ao--- 400.00m

FOR CLUSTER:

    # lvchange -aey lv01  (In Cluster - Activate in one node)
    # lvchange -aly lv01  (In Cluster - Activate in local node)
    # lvchange -aln lv01  (In Cluster - deactivate in local node)

READ/WRITE PERM CHANGE FOR LV:

[root@rhel6-client1 ~]# lvchange -pr /dev/vg01/lv02Fvg01
  Logical volume "lv02Fvg01" changed

[root@rhel6-client1 ~]# lvdisplay /dev/vg01/lv02Fvg01
  --- Logical volume ---
  LV Path                /dev/vg01/lv02Fvg01
  LV Name                lv02Fvg01
  VG Name                vg01
  LV UUID                4FzNKe-ynpl-quer-z7oA-lZck-8aUV-3kDY0h
  LV Write Access        read only ççç
  LV Creation host, time rhel6-client1, 2017-04-01 14:56:32 +0530
  LV Status              available
  # open                 1
  LV Size                300.00 MiB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

[root@rhel6-client1 ~]# lvchange -prw /dev/vg01/lv02Fvg01
  Logical volume "lv02Fvg01" changed

[root@rhel6-client1 ~]# lvdisplay /dev/vg01/lv02Fvg01
  --- Logical volume ---
  LV Path                /dev/vg01/lv02Fvg01
  LV Name                lv02Fvg01
  VG Name                vg01
  LV UUID                4FzNKe-ynpl-quer-z7oA-lZck-8aUV-3kDY0h
  LV Write Access        read/write ççç
  LV Creation host, time rhel6-client1, 2017-04-01 14:56:32 +0530
  LV Status              available
  # open                 1
  LV Size                300.00 MiB
  Current LE             75
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

To force the complete resynchronization of a mirror,

[root@rhel6-client1 ~]# lvchange --resync /dev/vg01/lv02Fvg01
  Unable to resync lv02Fvg01.  It is not RAID or mirrored.



No comments:

Post a Comment