The AIX LVM command migratepv can be used to exchange physical volumes in mirror copies of logical volumes. In the second part we want to take a closer look at how the migratepv command works in the case of mirrored logical volumes with 3 copies.
3rd Case: Mirrored Logical Volume (3 Copies)
In the case of a mirrored logical volume with 3 mirror copies, it is not possible to temporarily add another mirror copy. (LVM only supports a maximum of 3 mirror copies). The mirror copy containing the source physical volume must therefore be removed before the target physical volume can be added in the form of a mirror copy.
After a mirror copy has been removed, 2 mirror copies remain. There are 3 different ways to add the third copy (as with migratelp):
- Variant 1: Insert the third mirror copy at the front, i.e. copy 2 becomes copy 3 and copy 1 becomes copy 2. The new copy is inserted as copy 1.
- Variant 2: Insert the third mirror copy in the middle, i.e. copy 2 becomes copy 3 and the new copy is inserted as copy 2.
- Variant 3: Attach the third mirror copy at the back as copy 3.
Which variant of migratepv is used depends on the mirror copies in which the source physical volume is used.
If the source physical volume is used in:
- Only in mirror copy 1, variant 1 is used.
- Only in mirror copy 2, then variant 2 is used.
- Only in mirror copy 3, then variant 3 is used.
- In several mirror copies (e.g. because strictness is not set to super-strict): The highest logical partition used by the source physical volume is decisive here. If the source physical volume is used in mirror copy 1 for this logical partition, then variant 1 is used, if the source physical volume is used in mirror copy 2, variant 2 is used and if the source physical volume is used in mirror copy 3, then variant 3 is used!
To illustrate how migratepv works, for the interesting case that physical volumes are used in multiple mirror copies, we create a small logical volume with the following mapping files:
# cat bad_mirror3_cp1.map
hdisk10:1-2
hdisk14:1-2
hdisk17:1-2
hdisk11:5-6
hdisk10:3-4
# mklv —m bad_mirror3_cp1.map vg00 10
lv00
# cat bad_mirror3_cp2.map
hdisk13:1-2
hdisk11:1-2
hdisk13:3-4
hdisk14:3-4
hdisk13:5-6
# mklvcopy —m bad_mirror3_cp2.map lv00 2
# cat bad_mirror3_cp3.map
hdisk16:1-2
hdisk16:3-4
hdisk11:3-4
hdisk17:3-4
hdisk16:5-6
# mklvcopy —m bad_mirror3_cp3.map lv00 3
# syncvg -l lv00
#
The logical volume then looks like this:

# lslv -m lv00
lv00:N/A
LP PP1 PV1 PP2 PV2 PP3 PV3
0001 0001 hdisk10 0001 hdisk13 0001 hdisk16
0002 0002 hdisk10 0002 hdisk13 0002 hdisk16
0003 0001 hdisk14 0001 hdisk11 0003 hdisk16
0004 0002 hdisk14 0002 hdisk11 0004 hdisk16
0005 0001 hdisk17 0003 hdisk13 0003 hdisk11
0006 0002 hdisk17 0004 hdisk13 0004 hdisk11
0007 0005 hdisk11 0003 hdisk14 0003 hdisk17
0008 0006 hdisk11 0004 hdisk14 0004 hdisk17
0009 0003 hdisk10 0005 hdisk13 0005 hdisk16
0010 0004 hdisk10 0006 hdisk13 0006 hdisk16
#
The hdisk11 (DC01) is used in all 3 mirror copies. The hdisk14 (DC02) and the hdisk17 (DC03) are used in 2 mirror copies. The aim would be to use only physical volumes from DC01 in mirror copy 1, only physical volumes from DC02 in mirror copy 2 and only physical volumes from DC03 in mirror copy 3.
The candidates as source physical volumes are clearly hdisk11 (DC01), hdisk14 (DC02) and hdisk17 (DC03). In our test environment we have the physical volumes hdisk12 (DC01), hdisk15 (DC02) and hdisk18 (DC03) available.
Since hdisk11 (DC01) occurs in all three mirror copies, it is advisable to replace it first.
Variant 1
We first decide to replace hdisk11 (DC01) and therefore variant 1 of migratepv. The graphic shows that the highest logical partition that hdisk11 (DC01) uses is LP 0008. (The hdisk11 is used there in the mirror copy 1, which brings us to variant 1.)
In variant 1, the mirror copies containing the source physical volume are first removed. The LV then only has 2 mirror copies. Then the target physical volume is inserted at the front as mirror copy 1. Since only physical volumes from DC01 are to be used in mirror copy 1, only hdisk12 (DC01) can be used as the target physical volume.
So we replace hdisk11 (DC01) for hdisk12 (DC01) using migratepv:
# migratepv -l lv00 hdisk11 hdisk12
We are again following the work of migratepv graphically.

First, the mirror copies that use the source physical volume are removed. Any gaps that arise are filled by moving mirror copies from the right.

Gaps in mirror copies were filled from the right.

Mirror copies 1 and 2 are shifted to the right to make space for the physical partitions of the target physical volume.

Moving physical partitions to the right creates space in mirror copy 1.

The space in mirror copy 1 is filled with physical partitions of the target physical volume.

The mirror copy 1 is synchronized.

The logical volume is now mirrored three times again.

The resulting logical volume then looks like this:
# lslv -m lv00
lv00:N/A
LP PP1 PV1 PP2 PV2 PP3 PV3
0001 0001 hdisk10 0001 hdisk13 0001 hdisk16
0002 0002 hdisk10 0002 hdisk13 0002 hdisk16
0003 0009 hdisk12 0001 hdisk14 0003 hdisk16
0004 0010 hdisk12 0002 hdisk14 0004 hdisk16
0005 0011 hdisk12 0001 hdisk17 0003 hdisk13
0006 0012 hdisk12 0002 hdisk17 0004 hdisk13
0007 0013 hdisk12 0003 hdisk14 0003 hdisk17
0008 0014 hdisk12 0004 hdisk14 0004 hdisk17
0009 0003 hdisk10 0005 hdisk13 0005 hdisk16
0010 0004 hdisk10 0006 hdisk13 0006 hdisk16
#
All physical partitions of mirror copy 1 are on physical volumes of DC01. The hdisk13 (DC02) and hdisk17 (DC03) are used in 2 mirror copies (copy 2 and 3).
In order to correct the mirror copies 2 and 3, either hdisk13 (DC02) can be replaced by hdisk15 (DC02) or hdisk17 (DC03) by hdisk18 (DC03). The replacement of hdisk13 (DC02) by hdisk15 (DC02) requires the synchronization of 6 physical partitions. The replacement of hdisk17 (DC03) by hdisk18 (DC03) requires the synchronization of only 4 physical partitions.
Variant 2
In the following we show the replacement of hdisk13 (DC02) with hdisk15 (DC02), even if 50% more physical partitions have to be synchronized. The graphic shows that the highest logical partition that hdisk13 (DC02) uses, is LP 0010. (The hdisk13 is used there in mirror copy 2, which brings us to variant 2.)
In variant 2, the mirror copies containing the source physical volume are first removed. The logical volume has then 2 mirror copies only. Then the target physical volume is inserted in the middle as mirror copy 2. Since only physical volumes from DC02 are to be used in mirror copy 2, only hdisk15 (DC02) can be used as the target physical volume.
So we replace hdisk13 (DC02) by hdisk15 (DC02) using migratepv:
# migratepv -l lv00 hdisk13 hdisk15
We are again following the work of migratepv graphically.

Mirror copies that contain the source physical volume are removed. Any gaps that arise are filled in from the right.

There are gaps in mirror copy 3.

The gaps in mirror copy 3 are filled by moving mirror copy 2.

This creates gaps in mirror copy 2 for the target physical volume.

The gaps in mirror copy 2 are filled by the target physical volume.

The new physical partitions in mirror copy 2 are synchronized.

The logical volume is again completely mirrored three times. Each mirror copy now only uses physical volumes from one data center.

# lslv -m lv00
lv00:N/A
LP PP1 PV1 PP2 PV2 PP3 PV3
0001 0001 hdisk10 0006 hdisk15 0001 hdisk16
0002 0002 hdisk10 0007 hdisk15 0002 hdisk16
0003 0009 hdisk12 0001 hdisk14 0003 hdisk16
0004 0010 hdisk12 0002 hdisk14 0004 hdisk16
0005 0011 hdisk12 0008 hdisk15 0001 hdisk17
0006 0012 hdisk12 0009 hdisk15 0002 hdisk17
0007 0013 hdisk12 0003 hdisk14 0003 hdisk17
0008 0014 hdisk12 0004 hdisk14 0004 hdisk17
0009 0003 hdisk10 0010 hdisk15 0005 hdisk16
0010 0004 hdisk10 0011 hdisk15 0006 hdisk16
#
Now all physical partitions of mirror copy 2 are also located on physical volumes of DC02. And mirror copy 3 also only uses physical volumes from DC03.
The work of migratepv in the case of a mirrored LV with 3 copies can be summarized as follows:
- Remove the mirror copies that use the source physical volume.
- Add a mirror copy for the destination Physical Volume (either at the front, in the middle, or at the back).
- Synchronization of the new mirror copy.
By cleverly using the way migratepv works, a correct mirroring between data centers can be established in many cases. Compared to reorgvg, significantly fewer physical partitions usually have to be copied. In addition, the administrator decides with migratepv exactly how the target layout should look like. With reorgvg, this cannot be influenced by the administrator.
You must be logged in to post a comment.