Start by making the following folders on a mount point called "/vol". "/vol" maps to a EBS volume. (For instructions on how to mount a EBS volume, refer to the post - Amazon EC2 - Mounting a EBS drive)
sudo mkdir /vol/etc
sudo mkdir /vol/lib
sudo mkdir /vol/log
Move all the default MySQL folders/files to the above folders
sudo mv /etc/mysql /vol/etc/
sudo mv /var/lib/mysql /vol/lib/
sudo mv /var/log/mysql /vol/log/
Point the MySQL paths to the EBS paths
sudo mkdir /etc/mysql
sudo mkdir /var/lib/mysql
sudo mkdir /var/log/mysql
sudo vi /etc/fstab
Append "/vol/etc/mysql /etc/mysql none bind" to /etc/fstab
Append "/vol/lib/mysql /var/lib/mysql none bind" to /etc/fstab
Append "/vol/log/mysql /var/log/mysql none bind" to /etc/fstab
sudo mount /etc/mysql
sudo mount /var/lib/mysql
sudo mount /var/log/mysql
The resulting /etc/fstab file should look similar to the following:
LABEL=cloudimg-rootfs / ext4 defaults 0 0
/dev/xvdb /mnt auto defaults,nobootwait,comment=cloudconfig 0 2
/dev/xvda3 none swap sw,comment=cloudconfig 0 0
/dev/xvdf /vol xfs noatime 0 0
/vol/etc/mysql /etc/mysql none bind
/vol/lib/mysql /var/lib/mysql none bind
/vol/log/mysql /var/log/mysql none bind
Start MySQL
sudo /etc/init.d/mysql start
Unmounting MySQL volume.
sudo /etc/init.d/mysql stop
sudo umount /etc/mysql
sudo umount /var/lib/mysql
sudo umount /var/log/mysql
Handy command for checking the mount status
df -h
No comments:
Post a Comment