croome.org

  • blogs
  • photos
  • contact
Home › Blogs › simon's blog

Convert EC2 data filesystems to LVM for Drupal & MySQL

simon — Mon, 24/12/2007 - 3:40am

We're going to remove /mnt and use the "disk" to create LVM filesystems for our data. This will let us take snapshots, allowing for much quicker backups.

This script is a slightly modified version of Paul Moen's from http://blog.dbadojo.com/2007/11/making-logical-volumes-on-ec2.html.

Paste the script below into a file:

#!/bin/sh
# Name: make_mnt_LV.sh
# Script to make EC2 /mnt into a LVM volume

modprobe dm-snapshot

umount /mnt
pvcreate /dev/sda2
vgcreate vg /dev/sda2
lvcreate -L30720M -n myvmdisk1 vg
mkfs -t ext3 /dev/vg/myvmdisk1
mkdir -p /data/mysql_master
mount /dev/vg/myvmdisk1 /data/mysql_master

lvcreate -L30720M -n myvmdisk2 vg
mkfs -t ext3 /dev/vg/myvmdisk2
mkdir -p /data/mysql_slave
mount /dev/vg/myvmdisk2 /data/mysql_slave

lvcreate -L30720M -n myvmdisk3 vg
mkfs -t ext3 /dev/vg/myvmdisk3
mkdir -p /data/mysql_backup
mount /dev/vg/myvmdisk3 /data/mysql_backup

lvcreate -L30720M -n myvmdisk4 vg
mkfs -t ext3 /dev/vg/myvmdisk4
mkdir -p /data/www
mount /dev/vg/myvmdisk4 /data/www

lvdisplay

mkdir -p /data/mysql_master/data
mkdir -p /data/mysql_slave/data

chown -R mysql:mysql /data/mysql_master
chown -R mysql:mysql /data/mysql_slave
chown -R mysql:mysql /data/mysql_backup

Make it executable and run it:

chmod +x /tmp/convert_mnt
/tmp/convert_mnt

Once it has finished, remove the old /mnt from /etc/fstab and add our new entries. Your /etc/fstab should look as follows:

cat /etc/fstab
# Legacy /etc/fstab
# Supplied by: ec2-ami-tools-1.3-15586
/dev/sda1 / ext3 defaults 1 1
/dev/sda3 swap swap defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/mapper/vg-myvmdisk1 /data/mysql_master ext3 defaults 0 0
/dev/mapper/vg-myvmdisk2 /data/mysql_slave ext3 defaults 0 0
/dev/mapper/vg-myvmdisk3 /data/mysql_backup ext3 defaults 0 0
/dev/mapper/vg-myvmdisk4 /data/www ext3 defaults 0 0

Now, reboot and hope it comes back up! If you didn't change the fstab, it almost certainly won't and you'll have to trash your instance and start again.

  • Drupal
  • EC2
  • Linux
  • LVM
  • simon's blog
  • Login or register to post comments

Services

suramdi616 — Fri, 26/02/2010 - 12:08pm

VPXL will increase the capability determine of the Corpora Cavernosa thus reserving more blood to record vpxl online the cavern making a longer and thicker erection. VPXL makes cell growth within the corpora cavernous itself.

  • Login or register to post comments

Services

kbuspopre943 — Mon, 15/02/2010 - 4:14pm

No bad post, write more

  • Login or register to post comments

Navigation

  • Blogs
  • Photos
  • Recent posts
  • blogs
  • photos
  • contact