MariaDB on ramfs

Updated at by

If MEMORY engine isn't sufficient for eg. functional testing, you can run mysql from ramfs pretty easily. After carefully tuning innodb_* parameters and granting privileges to test users, create a "clean" copy of datadir.

# service mysql stop
Shutting down MySQL..                                      [  OK  ]
# rsync -a /var/lib/mysql/* /var/lib/mysql_derp

Cleanup old datadir /var/lib/mysql for some mounting action and add ramfs to /etc/fstab, check uid+gid for mysql:mysql

none          /var/lib/mysql      ramfs   defaults,gid=496,uid=497    0 0

Mount it!

mount -a

Horrible hack to rsync the /var/lib/mysql_derp to /var/lib/mysql during service startup. Create /etc/sysconfig/mysql (doesn't exist at least on my centos6.5 + mariadb10 installations:) containing following:

if [ "$mode" = "start" ] ; then
    rsync -a --delete /var/lib/mysql_derp/ /var/lib/mysql/

When calling mysql init script /etc/init.d/mysql it declares a nice variable $mode and sources the file created above.

Share on FacebookShare on Facebook Share on TwitterShare on Twitter

Leave a comment