Created
September 17, 2012 13:32
-
-
Save juliendsv/3737284 to your computer and use it in GitHub Desktop.
Speedup mysql by using RAMDISK
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/bash | |
sudo mkdir /db/tmpfs | |
sudo mount -osize=256m tmpfs /db/tmpfs -t tmpfs | |
sudo chmod 777 /db/tmpfs | |
# IMPORTANT edit your /etc/apparmor.d/usr.sbin.mysqld | |
# to match your new path | |
# so /var/lib/mysql -> /db/tmpfs/mysql/ (there must be 2 links) | |
# Then restart apparmor /etc/init.d/apparmor restart | |
# You must have stop properly you mysql instance before copying this | |
sudo cp -r /var/lib/mysql /db/tmpfs/mysql | |
sudo chown -R mysql:mysql /db/tmpfs/mysql | |
sudo service mysql stop | |
sudo service mysql start | |
# Then modify /etc/mysql/my.cnf | |
# update datadir like this : | |
# datadir = /db/tmpfs/mysql | |
# | |
# To have persistent tmpfs with reboot put the following into /etc/fstab. On this system the mysql user is uid/gid of 27, yours might vary so | |
# adjust accordingly. | |
# tmpfs /db/tmpfs tmpfs rw,uid=27,gid=27,size=256M,nr_inodes=10k,mode=0755 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment