MySQL VM with zfs data/log datasets

0verdrive

New Member
Oct 24, 2024
1
0
1
I'm new to ProxMox and am trying to figure out how to set up an optimized VM for a MySQL server. (As a side-note, I'm using a VM rather than lxc because I want to tweak some kernel parameters for mysql tuning. I know that I'm probably spending more time than it's worth trying to optimize the kernel, filesystem, and mysql configuration, but it's partly an exercise in understanding how all the components fit together).

I have a mirrored zfs pool (Tank1) with 990 Pro SSD nvme drives. I've read quite a few articles on how to tune zfs for mysql with different recordsize and other attributes for the data and log directories. However, I'm not clear what the best approach is for using zfs within a VM.


Option 1: Different zfs datasets for VM, mysql data, and log created in Proxmox and exposed via NFS to the VM

Proxmox zfs dataset configs (only a few attrs shown to highlight differences):
Code:
Tank1/VMs/Mariadb
        recordsize = 16K
    Tank1/Database/data
        recordsize = 16K
        logbias = throughput
    Tank1/Database/log
        recordsize = 128K

MariaDB VM primary hard disk is pointed to Tank1/VMs/Mariadb, and a different lxc uses NFS to expose ProxMox's Database/data and Database/log datasets for the MariaDB VM to use.

My concern with this approach is that it introduces NFS as an intermediary for disk access. NFS may negate or change some of the dataset tweaks that were configured for Mysql data/log rather than for sharing via NFS. Additionally I'm not clear how much of a performance impact this may have for MariaDB to access the data/log directories over NFS.


Option 2: zfs VM dataset created, and another zfs pool/datasets created inside the VM for Mysql data and log dirs

Code:
Proxmox zfs dataset configs:
    Tank1/VMs/Mariadb
        recordsize = 16K
    Tank1/Database/Mariadb
        recordsize = 16K (??)

MariaDB VM primary hard disk is pointed to Tank1/VMs/Mariadb. Secondary hard drive pointed to Tank1/Database/Mariadb as unpartitioned drive to be configured with zfs inside the VM

Code:
MariaDB-VM zfs dataset configs:
    Tank2/Database/data
        recordsize = 16K
        logbias = throughput
    Tank2/Database/log
        recordsize = 128K

This provides direct access to a zfs dataset from within the MariaDB VM - but nests one zfs pool inside the Proxmox Tank1/Database/Mariadb dataset. I'm guessing that this will cause both zfs datasets to manage data changes (syncs, etc) and I don't know what sort of performance hit this will have.


I don't know which of the above approaches are most likely to provide the best performance, or if there is another approach that I haven't considered. If anyone has any advice, I'd appreciate it!

For reference, here are some of the mysql and kernel tuning articles:
https://openzfs.github.io/openzfs-docs/Performance and Tuning/Workload Tuning.html#mysql
https://www.percona.com/blog/mysql-zfs-performance-update/
https://klarasystems.com/articles/o...tices-and-use-cases-part-3-databases-and-vms/
 
Last edited: