We wil demostrate this method by creatign a LVM based disk array.
Creating the LVM Disk Array
Based on environment w/ two disks:
/dev/xvdb
/dev/xvdc
0. Setup prequistions
sudo apt-get -y install lvm2 xfsprogs1. Create physical volume for the two devices
sudo pvcreate /dev/xvdb /dev/xvdc2. Create a Volume Group
sudo vgcreate vg_data /dev/xvdb /dev/xvdc3. Create new logical volume from all the space on the disks:
sudo lvcreate -l 100%FREE -n data vg_data4. Create xfs file system
sudo mkfs.xfs -f /dev/vg_data/data5. Mount the disk
sudo echo "/dev/vg_data/data /var/lib/mongodb xfs defaults 0 2" >> /etc/fstab && sudo mount -a
sudo chown -R mongodb:mongodb /var/lib/mongodbNote: This method may be effective only when you have large number of disks (>3) and relatively high disk space utilization. Otherwise, you may face high IOPS utilization only on part of the disks as can be seen below
avg-cpu: %user %nice %system %iowait %steal %idle
3.77 0.00 0.42 0.14 0.02 95.65
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
xvda 0.00 0.00 0.00 0 0
xvdb 176.00 0.00 21294.00 0 42588
xvdc 8.00 0.00 16.00 0 32
dm-0 170.00 0.00 20560.00 0 41120
Choosing LVM can be a great soluton to support your big data intallation. However, you should test your case to verify it is the right solution for your needs,
Keep Perforrming,
Moshe Kaplan