Configuring MariaDB for systemd
Configuring MariaDB under systemd: drop-in files, timeouts, open-file and core-size limits, LimitMEMLOCK (io_uring, aio), syslog, home access, umask, data directory, socket activation, and converting
Configuring systemd for MariaDB Development
#!/bin/bash
#
# Fixes needed for openSUSE (systemd) to be able to run and develop MariaDB
# without having to install it as a service
# This script needs to be run as root
set -e
# ── systemd limits ────────────────────────────────────────────────────────────
mkdir -p /etc/systemd/system.conf.d
cat > /etc/systemd/system.conf.d/memlock.conf << 'EOF'
# Needed for io_uring asynchronous IO used by InnoDB
[Manager]
DefaultLimitMEMLOCK=infinity
EOF
cat > /etc/systemd/system.conf.d/nofile.conf << 'EOF'
# Databases need a lot of open files
[Manager]
DefaultLimitNOFILE=65535
EOF
cat > /etc/systemd/system.conf.d/bigcore.conf << 'EOF'
# Allow big cores (needed to be able to debug MariaDB core files)
[Manager]
LimitCORE=infinity
EOF
# Apply systemd changes
systemctl daemon-reexec
# ── sysctl ────────────────────────────────────────────────────────────────────
mkdir -p /etc/sysctl.d
cat > /etc/sysctl.d/50-aio.conf << 'EOF'
# Fix "io_setup(1024) returned Unknown error -11 when running mtr tests"
fs.aio-max-nr=1048576
EOF
cat > /etc/sysctl.d/50-coredump.conf << 'EOF'
# Store core files in the current directory
kernel.core_pattern=core.%p
EOF
cat > /etc/sysctl.d/50-perf_event_paranoid.conf << 'EOF'
# Allow usage of perf/RR
kernel.perf_event_paranoid=1
EOF
# Apply sysctl changes
sysctl --system
# ── PAM limits ────────────────────────────────────────────────────────────────
mkdir -p /etc/security/limits.d
cat > /etc/security/limits.d/nofile.conf << 'EOF'
# Takes effect on next login
* soft nofile 65535
* hard nofile 65535
root soft nofile 65535
root hard nofile 65535
EOF
echo ""
echo "Done. PAM (number of open files) limits (/etc/security/limits.d/nofile.conf) will take effect on next login."Configuring the Systemd Service
Useful Systemd Options
mariadbd-safe option
systemd option
Comments
Configuring the Systemd Service Timeout
Configuring the Open Files Limit
Configuring the Core File Size
Configuring MariaDB to Write the Error Log to Syslog
Configuring LimitMEMLOCK
Configuring Support for io_uring Asynchronous IO in InnoDB
Increasing the Limit for aio
Configuring Access to Home Directories
Configuring the umask
Configuring the Data Directory
Systemd Socket Activation
Using Systemd Socket Activation
When to Use Systemd Socket Activation
Downsides to Using Systemd Socket Activation
Configuring Systemd Socket Activation
Extra Port
Multi-Instance Socket Activation
Systemd Socket Activation for Hosting Service Providers
End User Benefits
Hosting Service Provider Benefits
Downsides to the Hosting Service Provider
Configuration Items for a Per-User systemd Socket-Activitated Multi-Instance Service
A MariaDB Template File
Custom Configuration for the Multi-Instance Service
Custom Configuration for the Multi-Instance Socket
Converting mariadbd-safe Options to Systemd Options
Last updated
Was this helpful?

