Comment 3 for bug 121527

Revision history for this message
Greg Copeland (gtcopeland) wrote :

This is not a bug but a user failure. I'm not an Ubuntu user but I just happened to stumble on this while looking for something else so I thought I would help you guys close this bug. As such, I've not tried to create a mirror under Ubuntu. Just the same, the user instructions above will fail on all LVM2 platforms as it is not being used properly.

To create an LVM mirror you MUST have THREE PVs available! From my limited experience, it appears the third PV (the log) only requires 4MB be available so creating a larger PV is nothing but a waste. The third PV can be created on a third disk or on one of the mirror'd disks (if partitions are used). Loss of the log only affects *cross-boot* synchronization/restoration so it is safe to use a third disk at the cost of safe mirror de-synchronization. I say safe because it will create the same potential issues as simply losing a mirrored disk or LV. Personally, I'd rather tie it to a disk involved in the mirror but performance is likely slightly better using a third disk. Below you can see I'm using two disks, not three as I believe this eases the failure detection and recovery picture slightly.

[root@localhost ~]# lvs -a -o +devices
  LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
  home mirror1 mwi-ao 200.00G home_mlog 24.47 home_mimage_0(0),home_mimage_1(0)
  [home_mimage_0] mirror1 Iwi-ao 200.00G /dev/sdb6(0)
  [home_mimage_1] mirror1 Iwi-ao 200.00G /dev/sdc6(0)
  [home_mlog] mirror1 lwi-ao 4.00M /dev/sdb5(0)

As you can see above, I'm rebuilding my mirror as we speak. The mirrored LV is home, in the mirror1 VG. It has three PVs in use; /dev/sdb6, /dev/sdc6 (to be 200G - mirrored), and /dev/sdb5 (the log).

To get the above do the following but with your own devices.
pvcreate /dev/sdb5 (>4MB log PV)
pvcreate /dev/sdb6 (mirror PV)
pvcreate /dev/sdc5 (>4MB log PV - redundant and not immediately used - used for recovery, if needed)
pvcreate /dev/sdc6 (mirror PV)

# The /dev/sdc5 is not required is is strictly optional - it also makes partitioning symmetrical
vgcreate mirror1 /dev/sdb6 /dev/sdc6 /dev/sdb5 /dev/sdc5

# dm-mirror must be loaded
modprobe dm-mirror

# The third PV MUST be the log PV (which is /dev/sdb5)
lvcreate -m1 --mirrorlog disk -L200G -n home /dev/mirror1 /dev/sdb6 /dev/sdc6 /dev/sdb5

To be clear, I've never actually created it as above, I normally do it as a two step process via some of the above followed by use of vgextend and then finally:
lvconvert -i5 -m1 --mirrorlog disk /dev/mirror1/home /dev/mirror1 /dev/sdb6 /dev/sdc6 /dev/sdb5

You can then monitor progress of the mirror build via the following command if you do it with lvcreate. Or if you used lvconvert with the -i5, it will update you the status every 5-seconds.
lvs -a -o +devices