Use EBS Volumes for Logs with MariaDB Xpand

Overview

Xpand recommends using a separate volume to store the Xpand logs as opposed to using the same volume as the database data. This prevents having the database and the logs compete for storage space and IO. With AWS, it is easy to add a small EBS volume to handle the logs. Here is how to proceed using the AWS console and ssh access to each Xpand node:

Create the EBS volume

In the AWS console EC2> Volumes, select "Create Volume", and use the settings below:

  • type: magnetic

  • size: 50GB

  • availability zone: pick the same one as the Xpand node

  • snapshot id: leave blank

  • encryption: leave unchecked

Click Create. The volume will take a minute before it is available. Create a volume for each Xpand node.

Attach the volume

Once ready, you can attach the volume to your Xpand instance:

  • select the volume you just created

  • click Action > Attach Volume, fill the form with

    • instance : select the Xpand node you want (you can search by id or tag name)

    • device: leave the default.

    • click Attach

  • Repeat for each Xpand node.

Setup the new volume

Once every node has an EBS volume attached, it needs to be set up on each node individually.

  1. Find the EBS volume. Below we are using an m3.xl instance with 2 ephemeral disks (xvdb and xvdc) that are in a raid0 (md0) used as a data volume.

    $ cat /proc/partitions
    major minor  #blocks  name
     202        0    8389632 xvda
     202        1    8389600 xvda1
     202       16   39313408 xvdb
     202       32   39313408 xvdc
       9        0   78561280 md0
     202       80   52428800 xvdf   <== this is the EBS volume
    
  2. Stop the database (this will stop the database on the node, and if clustered, on every node of the cluster).

    $ clx dbstop
    
  3. Format the volume with ext4.

    $ mkfs -t ext4 /dev/xvdf
    
  4. Create mount point, label the volume, update fstab, and mount the volume.

    $ mkdir -p /var/log/clustrix
    $ e2label /dev/xvdf CLUSTRIX-LOG
    $ echo 'LABEL=CLUSTRIX-LOG /var/log/clustrix ext4 defaults,noatime,nodiratime 0 2'>> /etc/fstab
    $ mount -a
    
  5. Move the old log directory to the new one.

    $ mv /data/clustrix/log/* /var/log/clustrix/.
    
  6. Create a symlink to the old directory (avoids config changes).

    $ rm -rf /data/clustrix/log
    $ ln -s /var/log/clustrix/ /data/clustrix/log
    
  7. Check that everything worked.

    $ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/xvda1      7.8G  1.5G  5.9G  21% /
    /dev/md0         74G  2.0G   68G   3% /data/clustrix
    /dev/xvdf        50G   53M   47G   1% /var/log/clustrix
    $ ls -l /data/clustrix/log
    lrwxrwxrwx. 1 root root 11 Aug  7 15:04 /data/clustrix/log -> /var/log/clustrix/
    
  8. Proceed with step 3 through 6 on all the other Xpand nodes.

  9. Start the database.

    $ clx dbstart