Mysql / Mariadb tmpdir on tmpfs
Par alex sbille le vendredi 4 avril 2014, 14:29 - System Administration Linux - Lien permanent
On spinning disks, write is dramatically slow for some applications, after tweaking my.cnf, I needed more.
So I'm setting up a tmpfs disk an put mysql tmpdir in it:
Prepare mysql config with only replace the tmpdir value with the future path:
nano /etc/mysql/my.cnf
Add or replace tmpdir value with
tmpdir = /var/lib/mysqltmp
Create the tmpfs with privileges:
Get uid and gid of mysql / mariadb
id mysql
uid=110(mysql) gid=113(mysql) groupes=113(mysql)
Add a line in the /etc/fstab
nano /etc/fstab
For 500 MB space:
tmpfs /var/lib/mysqltmp tmpfs rw,gid=113,uid=110,size=500m,mode=0750,noatime 0 0
No need to restart, just
mount -a && service mysql restart
[ ok ] Stopping MariaDB database server: mysqld. [ ok ] Starting MariaDB database server: mysqld . .. [info] Checking for corrupt, not cleanly closed and upgrade needing tables..
df -h
tmpfs 500M 0 500M 0% /var/lib/mysqltmp