tags:

views:

4354

answers:

7
+6  Q: 

RAID verses LVM

If I were to consider between LVM (Logical Volume Management) and RAID, would I have to choose between the two, or would they go hand in hand? Which one would should I choose over the other, for various setups (say, database server, file server, workstation etc). Comparison would be great.

+2  A: 

They are two pretty different things, and you can (and are sometimes recommended to) use both. I don't have time to go into details, but I'd suggest looking into various RAID/LVM documentation/HOWTOs available on the Internet.

Jack Leow
+5  A: 

They are different things. With RAID you try to get redundancy (usually) out of disks. With LVM you allocate disk space flexibly. If you want redundancy, use RAID. If you want flexibility, use LVM. If both, use LVM over RAID. Sometimes RAID capability is part of LVM. In many situations you need flexibility and therefore LVM.

LVM RAID

+9  A: 

They can seem comparable at first sight, because LVM lets you use several drives as one, and RAID is all about joining drives; but they're totally different in fact.

RAID is used to join several drives as a single volume. Different RAID schemes let you increase capacity, speed, reliability, or all. In the end, you get with something that is just like one bigger, faster, better drive.

LVM is a very flexible volume manager. Although it has a couple of RAID modules, if you want RAID's redundancy or speed, put LVM on top of a RAID (or several). The purpose of LVM is joining several volumes (can be drives or RAIDs or a mix) into a 'Volume Group'. Then, you create new 'Logical Volumes' from the group. That gives you a lot of flexibility because you can later reassign capacity between the Logical Volumes, and add or remove Physical Volumes from the Volume Group. It really lets you think in a different way about storage.

typical use cases:

  • a workstation can sometimes benefit from LVM if you want to have a "better partition than partitions"; but usually a single partition is enough and easier to handle. Also RAID1 (mirroring) is nice because the extra speed and stability, especially now that storage is so cheap.

  • a file server can use LVM to grow at any time, and usually the physical volumes you add to the volume group are RAIDs, so you can get extra reliability and uptime. Also, you can assign and reassign storage to different sharepoints.

  • a DB server needs the ultimate in seek time, neither RAID nor LVM help here (besides a little higher concurrency with RAID1). Usually DBs use a simple RAID1 of very fast (and low capacity) SAS drives (10-15krpm), at least for the indexes. sometimes you put the data on slower (and cheaper) disks, on RAID1,5 or 6

Javier
Doesn't RAID1(mirroring) make no difference to seek speed, or possibly even slow it down, since it has to write the data twice? It's benefit is so if one drive dies, you lose no data.
dbr
for writes it's usually no difference with DMA hardware (all since at least 10 years ago). for reads there's a little advantage because you can read from either drive.
Javier
+3  A: 

The first question I have is a simple one. Software or hardware RAID? Do note that LVM is software RAID.

Hardware RAID while looking good on paper is not something I suggest implementing in todays hostile server world. If your disk controller dies, and you can't find a replacement, or the replacement has a different firmware version and the two are incompatible, your data is stuck on the disks with little to no chance of recovery, especially because many different RAID controllers implement different on-disk RAID structures. Software RAID is a lot easier to fix by just moving the drives to a new server and telling Linux how to look at the disks correctly.

Software RAID is perfectly fine, as long as you aware of the limitations. WIkipedia's RAID article contains some information on the different levels of RAID. There are several caveats that should be mentioned. RAID-5 looks good for redundancy, but beware of the write-hole.

LVM basically is traditional software RAID. It allows you to create RAID-0, and RAID-1. It provides to the OS one logical "drive" to have a file system on top, and since LVM is software it can also provide other features, like snapshots. Wikipedia's LVM (Linux) article is not too informational, but it will give you a general idea of what you can do with it. Note, EVMS which was introduced in Linux kernel 2.4.x does support RAID-5.

An issue that both software and hardware RAID-5 have to contend with, as I mentioned before, is the write-hole, besides the write-hole there are other issues with RAID-5 in that you won't notice if it is corrupting data in such a way that when your drive fails the next time, and it attempts to XOR the data across the disks to let a read finish that it gives you back bad data. This alone has caused new file systems to be created that attempt to solve the problem (ZFS, btrfs). The other RAID levels all have their own issues to deal with. For example a RAID mirror means you "lose" an entire second disk in the name of redundancy. (For example, two disks sized at 200 GB each, so a total of 400 GB would mean only 200 GB usable).

You are able to use both hardware RAID and software RAID in accordance with each other. Hardware RAID is discouraged unless it is absolutely required, however even those times are changing, for example Sun with OpenSolaris and ZFS suggests that you let ZFS handle the management of the disks, and RAID, mainly because it is designed to do it well, and has less of the issues associated with hardware RAID controllers. Until reliability of the controllers improves, and or the algorithms used to store the data on disk, software RAID is the way to go.

X-Istence
Are you sure about hardware RAID being discouraged..? Hardware RAID is far more reliable (if power is lost, they retain the write buffer using a battery, so you don't lose the last lump of data), and generally much more recommended than using the software equivalent..
dbr
Yes, battery backed up writes will give you improvements even if you don't use the hardware RAID. Hardware RAID controllers can silently corrupt data, and not know it. Jeff Bonwick explains: http://blogs.sun.com/bonwick/entry/raid_zAlso, software RAID is far more flexible, and easier to recover.
X-Istence
A: 

Personally I'd say, use LVM for any server installation, but don't use software RAID at all.

Software RAID gives you none of the benefit of hardware RAID, but all of the drawbacks.

MarkR
I am not so sure if hw is better than sw. And if you listen to podcast 48 (http://blog.stackoverflow.com/2009/04/podcast-48/, start 42m20s), both Joel and Jeff "discredit" hw raid but is positive to sw.
hlovdal
A: 

X-Istence's explanation in paragraph 2 of his post explains why sw raid is the best. Who is to say you are going to have the necessary Areca raid card and driver to recover from a disk failure. I will always be able to get a copy of linux to recover with. Even in the deepest darkest depths of nowhere, like where they build dams and powerstations.

and i assure you my dual socket 8 core Xenon server board makes a better raid card than any of those add-on hw raid card. If not, add more server mobos, repeat, etc. Pretty soon you are sitting in a storage cluster. This is how the big boys play.

Meggawhat
A: 

I have used software raid since 1998 (when it came with a BIG FAT WARNING) and it's been great! Never had a software raid related failure.

Andrew