Ensure there are no MariaDB or MySQL CE libraries already installed (some of these have shipped by default on some distributions)....
sudo su - root
yum list installed | grep -i maria
yum list installed | grep -i mysql
To remove, if necessary, use...
yum remove mariadb-libs.x86_64
yum remove mysql-community-*
yum remove mysql-release-el7.x86_64
yum clean all
sudo dnf install -y libaio numactl-libs perl wget tar
/etc/sysctl.d/mysql.conf
vm.swappiness = 1
vm.overcommit_memory = 0
fs.aio-max-nr = 1048576
fs.file-max = 1000000
net.core.somaxconn = 65535
sudo sysctl --system
XFS (preferred) or EXT4.
/var/lib/mysql should be created as a distinct mount point sized to hold the expected aggregate size of the database files. If expected database size is not known, a sensible default is 50GB.
/backup should be created as a distinct mount point sized to hold the expected size of at least one complete backup. If expected database size is not known, a sensible default is 50GB.
Mount options...
noatime,nodiratime,relatime
If you use an RPM or DEB install (i.e. YUM or APT), then this will be done automatically.
sudo semanage fcontext -a -t mysqld_db_t "/data/mysql(/.*)?"
sudo restorecon -Rv /data/mysql
sudo aa-status
sudo nano /etc/apparmor.d/usr.sbin.mysqld
AppArmor
sudo firewall-cmd --add-service=mysql --permanent
sudo firewall-cmd --reload
firewalld
sudo ufw allow 3306/tcp
ufw
Transparent Huge Pages should be disabled.
Check with...
cat /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
NUMA imbalance can lead to severe stalls under high load.
If NUMA exists, best practice:
Bind mysqld to all nodes equally, or
Disable NUMA in BIOS, or
Run mysqld with numactl:
numactl --interleave=all mysqld
MySQL replication and GTIDs depend on correct time. Use tools like chrony.
MySQL prefers low or zero swap usage. Best practice:
Swap enabled but small (1–2 GB)
swappiness=1 (as in sysctl above)
Never disable swap on production.
If the hostname cannot be resolved, MySQL startup or replication may hang.
Check with...
hostname -f
getent hosts $(hostname -f)