Running MySQL on Amazon EC2 with EBS

I have a server on which MYSQL cannot be copied. In this instance, there is a root device with EBS support (/ dev / sda1) that constantly stores files. It is not clear to me whether MYSQL data and binary log files are constantly stored.

Should he do this if it is installed in the root? I would think so.

Should I instead mount and mount another volume and then point the MYSQL server to a new location?

My commands are as follows (plus locking the MYSQL table when creating a snapshot)

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 

I am not a sys admin expert, and I don't want to corrupt an existing database. Is there any risk here? Should I even worry about an additional device here or just stick with the built-in root device?

+4
source share
3 answers

I moved the / etc / mysql and / var / lib / mysql directories to my EBS and created symbolic links in my previous places.

Thus, I did not have to change the configuration files or worry about something without finding the files.

The reason I also moved / etc / mysql was because the configuration files and script maintenance would not be lost if I linked EBS to another instance.

As for backing up this data, it would be better to create another instance and create a master / master configuration so that you also get the benefits of switching to another resource.

+7
source

If you are concerned about data retention:

Take a snapshot of / dev / sda 1, create a completely separate copy (t1.micro will do this fine), create a new volume based on the snapshot taken from / dev / sda 1, then mount this new volume on a new separate copy? If your data is present on a new volume, it is definitely stored in EBS on / dev / sda 1.

Having said that: many Linux images are configured by default to automatically terminate the root volume (/ dev / sda1) when the instance finishes. Meaning: if you ever lose an instance, you also lose all your data on the volume if you do not have it elsewhere. An easy way to store backups is to simply use EC2 for daily snapshots. It is very easy to create a script that takes a snapshot and deletes the old daily periodic snapshots after the completion of a new snapshot. If you are looking for smaller backup sizes or incremental backup strategies, you can write more complex scripts that run t1.micro in an alternative availability zone or area, back up only MySQL data through any mechanism you like, and then turn off the instance t1.micro.

+3
source

If you stop your instance, it will look like a regular shutdown, and the volume of EBS should remain with all the data. If you complete the instance, than, I think, all the data from the moment the snapshot disappears.

But usually I don’t see a big reason to stop it. In any case, try on a test instance. You can simply write several files and see what happens in different use cases.

This way, you will also feel much safer than just relying on someone.

+2
source

All Articles