Running MySQL on Amazon EC2 with EBS (Elastic Block Store)

https://aws.amazon.com/articles/1663

Configuring MySQL to use the EBS volume

Now that we have an EBS volume mounted on the instance with a good file system, let’s put the MySQL database on that volume and tell MySQL where it is.

Stop the MySQL server.

sudo /etc/init.d/mysql stop

Move the existing database files to the EBS volume. Point MySQL to the correct database files on the EBS volume using mount bind.

sudo mkdir /vol/etc /vol/lib /vol/log
sudo mv /etc/mysql     /vol/etc/
sudo mv /var/lib/mysql /vol/lib/
sudo mv /var/log/mysql /vol/log/

sudo mkdir /etc/mysql
sudo mkdir /var/lib/mysql
sudo mkdir /var/log/mysql

echo "/vol/etc/mysql /etc/mysql     none bind" | sudo tee -a /etc/fstab
sudo mount /etc/mysql

echo "/vol/lib/mysql /var/lib/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /var/lib/mysql

echo "/vol/log/mysql /var/log/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /var/log/mysql

Restart the MySQL server.

sudo /etc/init.d/mysql start
  •  
  •  
  •  
  •  

Viet Luu has written 318 articles

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

We are thankful for your never ending support.

Leave a Reply