Cloud Zone is brought to you in partnership with:

' ! Moshe Kaplan constantly helps successful firms getting to the next level and he is thrilled to uncover some of his secrets. Mr. Kaplan is a seasoned project management and cloud technologies lecturer. He is also known to be a cloud and SCRUM evangelist Moshe is a Co-Founder. He was a R&D Director at Essence Security, led RockeTier and served as a board member in the IGT and as a department head at a top IDF IT unit. Moshe holds M.Sc and B.Sc from TAU. Moshe is a DZone MVB and is not an employee of DZone and has posted 59 posts at DZone. You can read more from them at their website. View Full User Profile

Stretching your Disk Space on Amazon's MySQL Server

  • submit to reddit
If you deal with large databases, you will probably need more than the provisioned storage of the default Amazon AMI (8GB).
The following 10 steps guide will help you expand your disk meet your business needs:
  1. Create a new storage volume at the Amazon console (or using AWS API). Make sure it is big enough to accommodate storage, log files, bin files and future growth. Notice! verify the new drive is in the same availability zone as the target instance.

  2. Write down the mount name you chosen. For example: /dev/sdf.

  3. Mount the disk to your system according to Chris Dean post:

    1. sudo mkfs.ext3 /dev/sdf where /dev/sdf is the mount name you chose.

  4. Shutdown the MySQL daemon: sudo /etc/init.d/mysql stop

  5. Move your current MySQL data directory to a temporary directory: sudo mv /var/lib/mysql  /var/lib/mysql.old

  6. Recreate the MySQL data directory and provide the needed permissions:

    1. sudo mkdir /var/lib/mysql

    2. sudo chown mysql:mysql  /var/lib/mysql

  7. Mount the new disk to the new directory:

    1. Add another line to /etc/fstab (sudo vi /etc/fstab): /dev/sdf /var/lib/mysql ext3 defaults 1 2

    2. Mount the disk: sudo mount /var/lib/mysql

    3. Verify everything is Okay with df

  8. Move the files from the temporary directory back to the new data directory sudo mv /var/lib/mysql.old/* /var/lib/mysql

  9. Remove the old directory: sudo rmdir  /var/lib/mysql.old

  10. Restart you MySQL: sudo /etc/init.d/mysql start

Bottom LineA combination of cloud knowledge, Linux sysadmin, MySQL expertise and careful work will help you go through the scale and growth challenges. 
Published at DZone with permission of Moshe Kaplan, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)