Deploying a standalone MariaDB Server VM

Find details as well as plans & pricing for the MariaDB Server Standalone offer in the Microsoft Azure Marketplace, and work through the deployment process.

After starting the deployment from the Azure Portal web interface, you'll need to wait about 5 minutes for it to complete. You can monitor the progress of the deployment by finding your Resource Group and either choosing Deployments under Settings or clicking the link under the Deployments heading in the Essentials section.

Connecting to the VM

After the deployment finishes, you will need to SSH to the MariaDB VM in order to connect to MariaDB Server using the MariaDB command-line client.

To find the SSH command to use, navigate to your Resource Group, select the Virtual machine, and click Connect at the top of the blade. Copy the SSH command to use, including the username and IP address, and paste it into a Linux/Unix shell or adapt it for use with PuTTY or similar. You're responsible for providing the SSH key or password used during deployment.

Connecting to MariaDB Server

Note that it is not possible to connect to the MariaDB Server directly (on port 3306) using the Public IP address.

To connect to MariaDB Server from another node, it should be an Azure VM with a Network interface in the same Virtual network and same Subnet as the MariaDB Server VM.

You will need to create a user in MariaDB Server in order for a client to be able to connect to it from another VM. You can choose to either provide the private IP address of the other VM, or you can create a user that has a wildcard IP address. The correct wildcard IP address to use depends on the IP address range of the subnet where you're deployed MariaDB Server. When you connect to the VM using SSH, you should get a message like this:

To create a MariaDB user that can connect from any other VM in this vnet,
execute CREATE USER or GRANT with host '10.0.0.%'.

Use the CREATE USER or GRANT statements to create a new user with that IP address. For example:

CREATE USER 'myuser'@'10.0.0.%' IDENTIFIED BY 'myPassword';

After creating the user, and granting it appropriate privileges to interact with one or more databases/schemas, have the application/client connect to MariaDB Server using the Private IP address of the MariaDB Server VM's Network interface. To find the Private IP address, navigate to your Virtual machine in the Azure Portal and choose Network interfaces under Settings. You'll find the Private IP address as one of the columns in the list view, or in the Essentials section of the Overview.

If you find that you have not deployed the MariaDB Server VM in the same Virtual network as an existing app server VM you want to connect to MariaDB Server, destroy your MariaDB Server deployment and deploy again, this time choosing the existing Virtual network.

Adding a data disk

The default deployment of the standalone MariaDB Server VM puts the data directory on the same volume as the Operating System. If you need more space, you should attach a new disk to the VM and migrate the MariaDB data directory to the new disk.

You can choose to add a disk through the Portal web interface, or you can do so using the Azure command-line interface. To attach a new disk using the CLI, execute a command like this:

azure vm disk attach-new <resource group> <vm name> <size in GB>

You can also add a data disk using the Azure Portal web-based user interface. Find your Resource Group, find the Virtual machine resource inside the Resource Group, find Disks under Settings, and choose Attach new to add a new data disk.

As soon a the operation completes, the disk should immediately become available to your VM as /dev/sdc. A convenience script is included in the VM image to format the new disk and migrate the data directory from the OS disk to the newly-attached disk. Simply execute mariadb_migrate_datadir as root.

The script will set up the new block device as a LVM Physical Volume, create a Volume Group called mariadb, create a Logical Volume called datadir, format the volume, mount it as /mariadbdata, create an entry in /etc/fstab so the volume is mounted on reboot, move /var/lib/mysql to /mariadbdata/mysql, and create a symlink from /var/lib/mysql to /mariadbdata/mysql.

For more advanced storage scenarios (mirroring, striping, etc.), modify mariadb_migrate_data or handle LVM management and data migration as you see fit.


Comments loading...