Follow Us on Twitter

Configure MySQL on Amazon EC2 to run on Elastic Block Store

by Jos van Otterloo on October 5, 2009 · 2 comments

Today I have finished setting up MySQL on EBS, Elastic Block Store, the Amazon persistent storage Webservice. EBS provides block level storage volumes for use with Amazon EC2 instances. Amazon EBS volumes are off-instance storage that persists independently from the life of an instance. After terminating an EC2 instance all data stored after launching the instance is lost. Storage on an EBS is persistent even in case of instance failure.

Using the following article Running MySQL on Amazon EC2 with Elastic Block Store I moved the following MySQL folders to my Block Store:

  • /etc/mysql
  • /var/lib/mysql
  • /var/log/mysql

After mounting the original MySQL folders to the relevant mount points on the EBS, the MySQL server needs to be restarted. Make sure MySQL is operational after the changes. Because additions have been made to the /etc/fstab file the machine image needs to be rebundled and registered in Amazon.

/etc/fstab is a system configuration file and is used to tell the Linux kernel which partitions (file systems) to mount and where on the file system tree. To test if the new configuration is solid a new database is created. Even after bringing down the machine the newly created database should be available.

When I launched an instance of my EC2 image I noticed the changes had no effect. The original image I have used as a starting point for my configuration, already configured MySQL to store its’ data on another location than the default data directory: /var/lib/mysql

Make sure to check the MySQL configuration file located in /etc/mysql/my.cnf for the configuration options:

  • datadir = /vol/mysql_data
  • tmpdir = /vol/mysql_data/tmp

Make sure that the folders are moved to the EBS and point the datadir and tmpdir to these folders on the EBS. Since the configuration file is located on the Block Store it is not necessary to rebundle the image after making the modifications.

Configure MySQL on Amazon EC2 to run on Elastic Block Store5.051
Ratings:
VN:F [1.8.4_1055]
Rating: 5.0/5 (1 vote cast)

{ 2 comments… read them below or add one }

Martin October 28, 2009 at 4:14 pm

Hi Jos, check this out: Amazon offers MySQL in the cloud: http://aws.amazon.com/rds/
That may be even more easy than configuring MySQL on your own EC2 instance.

UN:F [1.8.4_1055]
Rating: +1 (from 1 vote)

Reply

Jos van Otterloo October 28, 2009 at 4:22 pm

Definitely worth a look, bookmarked it already, didn’t have time to look into it yet.
My first guess it is easier than configuring MySQL on an EC2 instance.

UA:F [1.8.4_1055]
Rating: 0 (from 0 votes)

Reply

Leave a Comment

 

Previous post:

Next post:

About Whitehorses
Company profile
Services
Technology

Whitehorses website

Home page
Whitebooks
Jobs

Follow us
Blog post RSS
Comment RSS
Twitter