Search This Blog

Friday, March 11, 2011

What storage solution is better – quick comparison between LVM mirroring and software RAID1 in Linux

With the introduction of LVM2 we have now the ability to create mirrors in LVM. It is relatively easy to set up configuration and works similar to RAID1.

At some point when playing with it you start asking yourself what is actually the technical difference between them two in Linux:
  • LVM mirroring
  • RAID1
For the end user it looks that both provide the same functionality of creating and maintaining a redundant block device. But are they very different from each other? Before I will give you couple of ideas to think about let me refresh just briefly how these 2 technologies are defined.

1. What is RAID (taken from the Red Hat docs)
13.1. What is RAID
...
RAID allows information to be spread across several disks. RAID uses techniques such as disk striping (RAID Level 0), disk mirroring (RAID Level 1), and disk striping with parity (RAID Level 5) to achieve redundancy, lower latency, increased bandwidth, and maximized ability to recover from hard disk crashes.

RAID distributes data across each drive in the array by breaking it down into consistently-sized chunks (commonly 256K or 512k, although other values are acceptable). Each chunk is then written to a hard drive in the RAID array according to the RAID level employed. When the data is read, the process is reversed, giving the illusion that the multiple drives in the array are actually one large drive.
....

2. Logical Volumes (taken from the Red Hat docs)
1.2. Logical Volumes
...
Volume management creates a layer of abstraction over physical storage, allowing you to create logical storage volumes. This provides much greater flexibility in a number of ways than using physical storage directly. With a logical volume, you are not restricted to physical disk sizes. In addition, the hardware storage configuration is hidden from the software so it can be resized and moved without stopping applications or unmounting file systems.
...

As we see the descriptions are quite different. So where the differences are going to be visible? Well, I was trying to find a good technical summary how this 2 techniques work but found only many small articles around on Google and in various docs.

Bellow is only a quick summary what could be good to know when trying to answer my question. For your information as well, the list is not meant to be complete and reflects only my personal state of knowledge.
  • How will the cache size in modern hard drives impacts the write and read operation of my block device? ( Storage Admin guide )
  • Is the read/write performance the same for LVM and RAID block devices? Looks, like it is not equal and RAID can manage a faster read throughput when accessing the data ( Linux md vs. LVM performance )
  • In RAID1 by default both disks are going to be used for read operations. This is the opposite for LVM, where by default only the ‘primary’ disk is used.
  • With LVM mirroring you can create more then only one mirror. A command like below will create for you 2 separate mirror block devices. In RAID1 you can have only one mirror and other devices will be consider as spare disk only.
# lvcreate -m 2 ...

  • You can detach the mirror from the ‘primary’ logical volume and start using it for whatever you want (backup, testing, ...). Doing this gives you immediately a copy of your primary logical volume but of course will remove the redundancy, at least temporarily. If you want to have the redundancy back you have to enable it again with a command like:
# lvchange -m ...
  • LVM supports snapshotting feature on logical volumes. At the time of writing this blog it can’t be used on the mirroring volume but you can always detach the mirror and start using it as a normal logical volume. As soon as it becomes a normal logical volume you can start creating snapshots.
# lvconvert --splitmirrors ...
# lvconvert -m1 ...
  • As long you have free space in your volume group you can have more then one snapshot.
  • For LVM mirroring you need by default more devices (+1 for the mirror device and +1 for the logs what together when you want to have only 1 mirror on a logical device you need 3 devices for it). This allocation policy, especially for logs can be changed and is controlled with the following options:
    • --mirrorlog (lvcreate)
    • --alloc anywhere (vgcreate)
  • Having a mirror in place don't limit you in use of other LVM features. It means you should be able to extend you logical volume by extending the physical volume it is base on. Once the local volume grows your file system on this block device can grow as well. All this can be done online without having to take the server off line or down.
  • Can you extend the file system so easily on the RAID1 device?
  • Depending on what mounting point are you trying to add to your system you may have some trouble during the boot phase with the default initrd (often it comes when you play with the /boot and / file systems as described here rhelv5-list - LVM mirroring )

Reference:

No comments:

Post a Comment