Created
May 2, 2012 09:51
-
-
Save laurynasl/2575624 to your computer and use it in GitHub Desktop.
load mysql to tmpfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When Ubuntu uses upstart, tmpfs can be mounted on /var/lib/mysql just before mysql start. | |
To do that, copy load_mysql_to_ramdisk to /usr/local/bin/load_mysql_to_ramdisk, | |
and apply modifications of modification_for_etc_init_mysql to /etc/init/mysql.conf | |
(I had to modify pre-start script by adding one line to the start, | |
and to create new post-start script). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
case "$1" in | |
start) | |
# stop before starting mysql | |
cp -Rp /var/lib/mysql /tmp/var_lib_mysql | |
mount -t tmpfs tmpfs /var/lib/mysql -o size=256m | |
cd /tmp/var_lib_mysql | |
cp -Rp * /var/lib/mysql/ | |
cd / | |
rm -rf /tmp/var_lib_mysql | |
;; | |
stop) | |
# stop after stopping mysql | |
umount /var/lib/mysql | |
;; | |
*) | |
echo "Usage: $SCRIPTNAME {start|stop}" >&2 | |
exit 3 | |
;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pre-start script | |
/usr/local/bin/load_mysql_to_ramdisk start | |
end script | |
post-stop script | |
/usr/local/bin/load_mysql_to_ramdisk stop | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment