HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to setup mysql on tmpfs?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
mysqlsetuptmpfshow

Problem

How to setup mysql on tmpfs ?

I am reading a tutorial in french, where the author do it this way :

1.) Create a tmpfs directory :

mkdir /var/tmpfs
mount -t tmpfs -o size=1G tmpfs /var/tmpfs
chown -R mysql:mysql /var/tmpfs/mysql


2.) Add it to fstab :

tmpfs  /var/tmpfs  tmpfs  nodev,nosuid,noexec,noatime,size=1G  0 0


3.) Copy MySQL to tmpfs (is ramfs here is correct?)

service mysql stop
cp -Rfv /var/lib/mysql /var/ramfs/
chown -R mysql:mysql /var/tmpfs/mysql


4.) Edit /etc/my.cnf

datadir /var/tmpfs/mysql


Then restart mysqld and you can optionally add a startup/stop script to backup the ram data to disk...

But I am not sure the above is right : did the writer of this tutorial mistake ramfs for tmpfs here ? He then goes on to use ramfs in the start/stop script, but what ramfs has to do there, isn't it really tmpfs only ?

Solution

Before you try doing this: take a look at mysql's "memory" storage engine. I would stick with that rather than having to deal with the many edge cases with e tmpfs.

http://dev.mysql.com/doc/refman/5.5/en/memory-storage-engine.html

we were considering the exact same scenario, but luckly ran across the memory engine, and have not had a problem since.

Context

StackExchange Database Administrators Q#20649, answer score: 2

Revisions (0)

No revisions yet.