Wednesday, April 16, 2014

Move MySQL tmp dir from Disk to RAM for better performance

        Move MySQL tmp dir from Disk to RAM for better performance
Cause:- If these temporary disk tables are causing serious I/O performance problems one could consider to use a RAM-disk instead of normal physical disks instead.

Goal :- Improve performance and decrease query time.

Solution:- Move MySQL's temporary files from disk to a RAM is very significant, if our server has lots of slow queries.

On Linux we have 2 possibilities to create a RAM-disk: ramfs and tmpfs.

#~~#Recommend to use tmpfs.
A RAM-disk can be created as follows:
shell> mkdir -p /db/ramdisk
shell> chown mysql:mysql /db/ramdisk
shell> mount -t tmpfs -o size=1024M tmpfs /db/ramdisk
To make this persistent we have to add it to the fstab:
#
# /etc/fstab
#
tmpfs           /db/ramdisk     tmpfs   rw,mode=1777,size=1024M    0       0

To changes and get it reflected this need to configure in my.cnf accordingly and restart the database...

No comments:

Post a Comment