Is there a recommended way to configure a mariadb container on LXD, in order to avoid disk i/o bottlenecks? What do you do?
I have a host with a mariadb zfs container which runs various mariadb databases that other containers are using (web applications). I have two disks with mirrored zpool configuration. Lately, the load on the host goes sky high (~ 30 or more) with high wait times. iostats shows 100% disk utilization and iotop shows mysqld is responsible. I read about tuning mariadb on ZFS, and I already setup these mariadb configuration parameters:
skip-innodb_doublewrite
innodb_use_native_aio=0
innodb_use_atomic_writes=0
These seem to help, but I occasionally still get 100% disk usage and high uptime load times.
I also read that it’s best to use separate zfs datasets for the Innodb table data, with recordsize=16K and for the Innodb log files, with recordsize=128K. How would I set these record sizes with LXD? Is it worth it to attach and configure two additional zfs devices to the container (for data and logfiles) with these recordsizes? Could I just set recordsize=16K for the whole container?
Should I move the mariadb container to an ext4 filesystem (with dir LXD storage)? If I did that, I would lose snapshots.
This is how I ended up setting a mariadb container, for use by other containers:
Create two zfs filesystems on the host, with record sizes 16K and 128K, as recommended.
Assuming that these two filesystems are z/mysql/data and z/mysql/log, I created a mariadb profile:
Verify that the correct filesystems are used by creating a database and checking that it is created in /var/share/mysql/data/
For snapshots, use zfs snapshots of the two filesystems (which can be done recursively on their parent filesystem). To make sure the snapshots have consistent data, use something like this: echo "flush tables with read lock;" | ssh mariadb.lxd sudo mysql | sudo zfs snapshot -r z/mysql@{name}
I suspect the issue is due to MariaDB tuning (or lack thereof). Suggest you download and run the MySQL tuner perl script and make sure the DB is properly tuned. https://github.com/major/MySQLTuner-perl