Setting Up MariaDB on an EC2 AMI


There are many different ways of setting up an EC2 AMI with MySQL, including using any of the pre-configured AMIs supplied by Amazon.

The default Getting Started AMI provided by Amazon uses Fedora Core 4, and you can install MariaDB by using yum:

shell> yum install mysql

This installs both the MariaDB server and the Perl DBD::mysql driver for the Perl DBI API.

Alternatively, you can use one of the AMIs that include MariaDB within the standard installation.

Finally, you can also install a standard version of MariaDB downloaded from the MariaDB Web site. The installation process and instructions are identical to any other installation of MariaDB on Linux. See , Installing and Upgrading MySQL.

The standard configuration for MariaDB places the data files in the default location, /var/lib/mysql. The default data directory on an EC2 instance is /mnt (although on the large and extra large instance you can alter this configuration). You must edit /etc/my.cnf to set the datadir option to point to the larger storage area.Important

The first time you use the main storage location within an EC2 instance it needs to be initialized. The initialization process starts automatically the first time you write to the device. You can start using the device right away, but the write performance of the new device is significantly lower on the initial writes until the initialization process has finished.

To avoid this problem when setting up a new instance, you should start the initialization process before populating your MariaDB database. One way to do this is to use dd to write to the file system:

root-shell> dd if=/dev/zero of=initialize bs=1024M count=50

The preceding creates a 50GB on the file system and starts the initialization process. Delete the file once the process has finished.

The initialization process can be time-consuming. On the small instance, initialization takes between two and three hours. For the large and extra large drives, the initialization can be 10 or 20 hours, respectively.

In addition to configuring the correct storage location for your MariaDB data files, also consider setting the following other settings in your instance before you save the instance configuration for deployment:

Once you have configured your AMI with MariaDB and the rest of your application stack, save the AMI so that you can deploy and reuse the instance.

Once you have your application stack configured in an AMI, populating your MariaDB database with data should be performed by creating a dump of your database using mysqldump, transferring the dump to the EC2 instance, and then reloading the information into the EC2 instance database.

Before using your instance with your application in a production situation, be aware of the limitations of the EC2 instance environment. See , "EC2 Instance Limitations". To begin using your MariaDB AMI, consult the notes on deployment. See , "Deploying a MariaDB Database Using EC2".

Retornar