dropdown menu

LVM - MIRROR POOL

Mirror Pool

Starting with 6.1 TL2 so-called mirror pools were introduced that make it possible to divide the physical volumes of a scalable volume group into separate pools. Mirror Pools allow to group physical volumes in a scalable volume group so that a mirror copy of a logical volume can be restricted to only allocate partitions from physical volumes in a specified group.

A mirror pool is made up of one or more physical volumes. Each physical volume can only belong to one mirror pool at a time. When creating a logical volume, each copy of the lv being created can be assigned to a mirror pool.

Mirro Pool name can be up to 15 characters long and is unique to the volume group it belongs to. Therefore, two separate volume groups could use the same name for their mirror pools.

Any changes to mirror pool characteristics will not affect partitions allocated before the changes were made. The reorgvg command should be used after mirror pool changes are made to move the allocated partitions to conform to the mirror pool restrictions.

------------------------------------------------------

Strict Mirror Pool:
When strict mirror pools are enabled any logical volume created in the volume group must have mirror pools enabled for each copy of the logical volume. (If this is enabled all of the logical volumes in the volume group must use mirror pools.)

mkvg -M y -S <hdisk list>                    creating a vg with strict mirror pool
chvg -M y <vg name>                          turn on/off strict miror pool setting for a vg (chvg -M n... will turn off)
lsvg <vg name>                               shows mirro pool sctrictness (at the end of the output: MIRROR POOL STRICT: on)

------------------------------------------------------

Super strict Mirror Pool:
A super strict allocation policy can be set so that the partitions allocated for one mirror cannot share a physical volume with the partitions from another mirror. With this setting each mirror pool must contain at least one copy of each logical volume.

mkvg -M s -S <hdisk list>                    creating a vg with super strict setting
chvg -M s <vg name>                          turn on/off super strict setting for a vg (chvg -M n... will turn off)
lsvg <vg name>                               shows mirro pool sctrictness (at the end of the output: MIRROR POOL STRICT: super)

------------------------------------------------------

Creating/Removing/Renaming a Mirror Pool (adding disk to a Mirror Pool):

mkvg -S -p PoolA hdisk2 hdisk4 bbvg                     <--creating a new VG with mirror pool
extendvg -p PoolA bbvg hdisk6                           <--extending a VG with a disk (while adding disks to mirror pools)

If we already have a vg:
root@bb_lpar: / # lsvg -P bbvg                          <--lists the mirror pool that each physical volume in the volume group belongs to
Physical Volume   Mirror Pool
hdisk6            None
hdisk7            None

root@bb_lpar: / # chpv -p PoolA hdisk6                  <--creating mirror pool with the given disks (disks should be part of a vg)
root@bb_lpar: / # chpv -p PoolB hdisk7                  (or if the mirror pool already exists, it will add the specified disk to the pool)


root@bb_lpar: / # lsvg -P bbvg
Physical Volume   Mirror Pool
hdisk6            PoolA
hdisk7            PoolB

root@bb_lpar: / # chpv -P hdisk7                        <--removes the physical volume from the mirror pool

root@bb_lpar: / # lsvg -P bbvg
Physical Volume   Mirror Pool
hdisk6            PoolA
hdisk7            None

root@bb_lpar: / # chpv -m PoolC hdisk6                  <--changes the name of the mirror pool

root@bb_lpar: / # lsvg -P bbvg
Physical Volume   Mirror Pool
hdisk6            PoolC
hdisk7            None

------------------------------------------------------

Creating/Mirroring lv to a Mirror Pool:

mklv -c 2 -p copy1=PoolA -p copy2=PoolB bbvg 10       <--creates an lv (with default name:lv00) in the given mirror pools with the given size
mklvcopy -p copy2=PoolB bblv 2                        <--creates a 2nd copy of an lv to the given mirror pool
mirrorvg -p copy2=MPoolB -c 2 bbvg                    <--mirrors the whole vg to the given mirror pool

------------------------------------------------------

Adding/Removing an lv to/from a Mirror Pool:

root@bb_lpar: / # lsvg -m bbvg                                <--shows lvs of a vg with mirror pools
Logical Volume    Copy 1            Copy 2            Copy 3
bblv              None              None              None

root@bb_lpar: / # chlv -m copy1=PoolA bblv                    <--enables mirror pools to the given copy of an lv
root@bb_lpar: / # chlv -m copy2=PoolB bblv

root@bb_lpar: / # lsvg -m bbvg                                <--checking again the layout
Logical Volume    Copy 1            Copy 2            Copy 3
bblv              PoolA             PoolB             None

root@bb_lpar: / # chlv -M 1 bb1lv                             <--disables mirror poools of the given copy for the lv

root@bb_lpar: / # lsvg -m bbvg                                <--checking again the layout
Logical Volume    Copy 1            Copy 2            Copy 3
bb1lv             None              PoolB             None

------------------------------------------------------

Viewing Mirror Pools:

lsmp bbvg                                  <--lists the mirror pools of the given vg

lspv hdisk6                                <--shows PV characteristic (at the last line shows mirror pool the pv belongs to)
lspv -P                                    <--shows all PVs in the system (with mirror pools)

lsvg -P bbvg                               <--shows the PVs of a VG (with mirror pools)
lsvg -m bbvg                               <--shows the LVs of a VG (with mirror pools)

lslv bblv                                  <--shows LV characteristics (at the end shows lv copies and the mirror) pools)

------------------------------------------------------

Correct steps of creating and removing a mirror pool (totally):

Mirror pool is a separate entity from LVM. (I imagine it as a small database, which keeps rules and strictness, so the underlying LVM commands, based on those rules are successful or not.) It can happen that you remove the 2nd copy of an LV with rmlvcopy (not in LVM anymore), but mirror pool commands will still show it as an existent copy. So make sure LVM commands (mirrorvg, mklvcopy...) and Mirror Pool commands (chpv -p, chlv -m copy1=.., chvg -M....) are in synchron all the time!


Mirror pool informations are stored in 3 places: PV, LV and VG
If you need to create or remove a mirror pool, make sure mirror pool entry is taken care it all 3 places.

Creating mirror pool on a VG which is already mirrored at LVM level:

0. check if mirrors are OK (each copy in separate disk)

1. chpv -p <poolname> <diskname>                <--add disks to the mirror pool
   # lspv hdisk0 | grep MIRROR
   MIRROR POOL:        PoolA


2. chlv -m copy1=PoolA fslv00                   <--add lv to the given pool (add all lvs to both pools: copy1 and copy2)
   # lslv fslv00 | grep MIRROR
   COPY 1 MIRROR POOL: PoolA
   COPY 2 MIRROR POOL: PoolB
   COPY 3 MIRROR POOL: None

3. chvg -M <strictness> <vgname>                 <--set strictness for the VG (usually chvg -M s ...)
   # lsvg testvg | grep MIRROR   
   MIRROR POOL STRICT: super

------------------------------------------------------

Removing mirror pool from a system:

1. chvg -M n <vgname>                            <--turn off strictness
   # lsvg testvg | grep MIRROR
   MIRROR POOL STRICT: off

2. chlv -M 2 <lvname>                            <--remove 2nd copy of the LV from mirror pool (remove 1st copy as well: chlv -M 1...)
   # lslv fslv00 | grep MIRROR
   COPY 1 MIRROR POOL: PoolA
   COPY 2 MIRROR POOL: None
   COPY 3 MIRROR POOL: None

If every mirror pool is removed from LV level, only then!:
3. chpv -P <diskname>                            <--remove disk from mirror pool (do it with all disks)
   # lspv hdiskpower0| grep MIRROR
   MIRROR POOL:        None

4. check with lsvg -m <vgname>

------------------------------------------------------

If you remove mirror pool from a disk, but it still exist on LV level (step 2 and 3 are not in correct order), you will get this:

# chpv -P hdiskpower0
0516-1010 chpv: Warning, the physical volume hdiskpower0 has open 
      logical volumes.  Continuing with change.
0516-1812 lchangepv: Warning, existing allocation violates mirror pools. 

     Consider reorganizing the logical volume to bring it into compliance.

# lsvg -m testvg
Logical Volume    Copy 1            Copy 2            Copy 3
loglv00           None              None              None
fslv00                              None              None        <--it will show incorrect data (Pool was not deleted at LV level)
fslv01            None              None              None

# chlv -M 1 fslv00                                                <--remove pool from LV level (copy 1)

# lsvg -m testvg                                                  <--it will show correct info
Logical Volume    Copy 1            Copy 2            Copy 3
loglv00           None              None              None
fslv00            None              None              None
fslv01            None              None              None

------------------------------------------------------

Changing from one Mirror Pool to another:

If you have a good working system with mirror pool (A and B) and requested to remove disks from pool A and assign new disks from Pool C:

My suggestion:
1. remove mirror pools totally from the system: from VG, LV and PV level
2. remove unnecessary mirror at LVM level (unmirrorvg from the disks of Pool A)
3. delete disks on the system (from Pool A) and assign new disks to the system (Pool C)
4. create LVM mirror to the new disks on Pool C (mirrorvg)
5. create new mirror pools, Pool A and C (PV, LV and VG level)

 ------------------------------------------------------
 
0516-622 extendlv: Warning, cannot write lv control block data.
0516-1812 lchangelv: Warning, existing allocation violates mirror pools.

Consider reorganizing the logical volume to bring it into compliance.


This can come up when you want to increase fs (or lv), but the lv layout on the disks is not following fully the mirror pool restrictions. (For example there is an lp which exists on a disk in one pool, but it should reside in the other pool.)

The reorgvg command can solve this (it can run for a long time):
reorgvg <vg name> <lv name>

 Sometimes reorgvg can't solve it and you have to  manually find where is the problem:

1. check lv - mirror pool distribution:

root@aixdb2: /root # lsvg -m P_NAVISvg
Logical Volume    Copy 1            Copy 2            Copy 3
p_admlv           VMAX_02           VMAX_03           None
p_datlv           VMAX_02           VMAX_03           None
p_archlv          VMAX_02           VMAX_03           None
...

As you see all of the 1st copy belongs to VMAX_02 and the 2nd copy to VMAX_03


2. check disk - mirror pool distribution

root@aixdb2: /root # lspv -P
Physical Volume   Volume Group      Mirror Pool
hdiskpower1       P_NAVISvg         VMAX_03    <--it should contain only 2nd copy of lvs
hdiskpower2       P_NAVISvg         VMAX_03    <--it should contain only 2nd copy of lvs
...
hdiskpower18      P_NAVISvg         VMAX_02    <--it should contain only 1st copy of lvs
hdiskpower19      P_NAVISvg         VMAX_02    <--it should contain only 1st copy of lvs
hdiskpower20      P_NAVISvg         VMAX_02    <--it should contain only 1st copy of lvs


3. check lv - disk distribution


From the output of lsvg -M <vg name>, you can see the 1st and 2nd copy of an lv resides on which disk.
After that you can check if that disk belongs to the correct mirror pool or not.

this will sort the disks with lvs on it and show which copy (1st or 2nd) is there:
root@aixdbp2: /root # lsvg -M P_NAVISvg | awk -F: '{print $1,$2,$4}'| awk '{print $1,$3,$4}'| sort -u | sort -tr +1 -n

P_NAVISvg:
hdiskpower18 t_datlv 1
hdiskpower18 t_oralv 1
hdiskpower19 p_datlv 2    <--2nd copy of p_datlv resides on hdiskpower19, but hdiskpower19 should contain only 1st copy
hdiskpower19 p_oralv 1
hdiskpower19 t_archlv 1

(the above command: lsvg -M...sort -tr +1 -n, was written for hdiskpower disks (-tr:delimeter is 'r'))
(if you have only hdisk, you can change it to lsvg -M...sort -tk +1 -n, or if you omit this sort, the command should work as well)


4. migrating the wrong lps to a correct disk

checking lps of an lv:
root@aixdb2: /root # lspv -M hdiskpower19 | grep p_datlv
hdiskpower19:889        p_datlv:9968:2
hdiskpower19:890        p_datlv:9969:2
hdiskpower19:891        p_datlv:9970:2

After finding the correct disk with free pps (e.g. this will show you the freepps: lspv -M <disk>):
root@aixdb2: /root # migratelp p_datlv/9968/2 hdiskpower2/329

(Sometimes for migratelp not enough to give diskname only (e.g. hdiskpower2), pp number is needed as well (e.g. hdiskpower2/329))

17 comments:

James Borg said...

Well done, well written and to the point.
I followed to clear issue for warning on mirrors. Thanks

aix said...

thanks...happy to see feedbacks like this :)

Bala said...

excellent work it really helped for me

aix said...

Thanks for the feedback...I'm happy to hear that :)

Anonymous said...

Good.

aix said...

:)

Anonymous said...

Hi aix,

What is the purpose of Mirror pool?At what time it can be useful for us?What is the advantage over rootvg mirroring and Mirror pool?

Thanks in Advance....

aix said...

Physical Volumes of a VG can be assigned to different Mirror Pools. Usually disks from1 storage box are assigned to 1 mirror pool and disks from other storage box to the other mirror pool (so in case of a storage box failure no loss will occur.) Later when you create a mirrored lv, each copy can be assigned to a mirror pool, and you don't have to keep in mind which disk to use, because mirror pool will keep strictness to no mix up copies and disks from different mirror pool (storage box). Rootvg cannot be assigned to Mirror Pools: http://www-03.ibm.com/support/techdocs/atsmastr.nsf/WebIndex/FQ130338

MaxiPad said...

This is good for:
* GLVM where one set of disks are in a different location, but not all allocations fit on one disk
* In VIO when using multiple LV backed devices from each of multiple VIO servers, all in the same client volume group.

Jai Ganesh said...

Hi,

Could you please explain about GLVM.

Cheers,
Jai

aix said...

Hi, I don't have any systems with GLVM, as soon I'll have one, I'll write about that.

-Balazs

Unknown said...

hi can help regarding hw we can lab practice online did u got any links

jst i want to practice at home

aix said...

Hi, I heard about this, but I have never tested it: http://www-304.ibm.com/partnerworld/wps/pub/systems/vlp/index

Puccu said...

Hi,

Is there a way to rename a mirror pool online (vg variedon and lv opened) ?

Thanks you.

aix said...

Hi, you can remove it and recreate it. (this can be done online)

Thorsten said...

Hi,
when I remove a MP whith chvg -Mn; chlv -M1 -M2 ; chpv -P
on a still mirrored VG - I get the followig message.

0516-1010 chpv: Warning, the physical volume hdisk3 has open logical volumes. Continuing with change.

As there are online LVs, this messeage is correct - but is it save to remove the MP with lvm mirror in place? To you get the message as well?

Thanks for any comment.
Thorsten

JOY GHOSH said...

excellent post