This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-14. For the latest, interactive version please visit https://mariadb.com/kb/.

Configuring Linux for MariaDB

Linux kernel settings

IO scheduler

For optimal IO performance running a database we are using the none (previously called noop) scheduler. Recommended schedulers are none and mq-deadline (previously called deadline). You can check your scheduler setting with:

cat /sys/block/${DEVICE}/queue/scheduler

For instance, it should look like this output:

cat /sys/block/vdb/queue/scheduler
[none] mq-deadline kyber bfq

Older kernels may look like:

cat /sys/block/sda/queue/scheduler
[noop] deadline cfq

Writing the new scheduler name to the same /sys node will change the scheduler:

echo mq-deadline >  /sys/block/vdb/queue/scheduler

The impact of schedulers depend significantly on workload and hardware. You can measure the IO-latency using the biolatency bcc-tools script with an aim to keep the mean as low as possible.

Resource Limits

Configuring the Open Files Limit

By default, the system limits how many open file descriptors a process can have open at one time. It has both a soft and hard limit. On many systems, both the soft and hard limit default to 1024. On an active database server, it is very easy to exceed 1024 open file descriptors. Therefore, you may need to increase the soft and hard limits. There are a few ways to do so.

If you are using mysqld_safe or mariadbd-safe to start mysqld, then see the instructions at mariadbd-safe: Configuring the Open Files Limit.

If you are using systemd to start mysqld, then see the instructions at systemd: Configuring the Open Files Limit.

Otherwise, you can set the soft and hard limits for the mysql user account by adding the following lines to /etc/security/limits.conf:

mysql soft nofile 65535
mysql hard nofile 65535

After the system is rebooted, the mysql user should use the new limits, and the user's ulimit output should look like the following:

$ ulimit -Sn
65535
$ ulimit -Hn
65535

Configuring the Core File Size

By default, the system limits the size of core files that could be created. It has both a soft and hard limit. On many systems, the soft limit defaults to 0. If you want to enable core dumps, then you may need to increase this. Therefore, you may need to increase the soft and hard limits. There are a few ways to do so.

If you are using mysqld_safe or mariadbd-safe to start mysqld, then see the instructions at mariadb-safe: Configuring the Core File Size.

If you are using systemd to start mysqld, then see the instructions at systemd: Configuring the Core File Size.

Otherwise, you can set the soft and hard limits for the mysql user account by adding the following lines to /etc/security/limits.conf:

mysql soft core unlimited
mysql hard core unlimited

After the system is rebooted, the mysql user should use the new limits, and the user's ulimit output should look like the following:

$ ulimit -Sc
unlimited
$ ulimit -Hc
unlimited

Swappiness

See configuring swappiness.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.