Have you ever been upset by the Linux tendancy to swap… Especially when trying to allocate a large InnoDB buffer pool.. Look at the following output:
yves@yves-laptop:~$ free
total used free shared buffers cached
Mem: 2041888 1991096 50792 0 52 954592
-/+ buffers/cache: 1036452 1005436
Swap: 975200 1308 973892
There is still 50792 + 52 + 954592 = 1005436 of free memory and Linux starts to swap!!! The reason is hidden here:
yves@yves-laptop:~$ cat /proc/sys/vm/swappiness
60
The swappiness controls the Linux to swap for the File cache. For a file server or a web server or even MySQL with MyISAM tables, the file cache is interesting but for InnoDB or NDB Cluster it is close to useless. Only put a “0″ in that proc entry (echo 0 > /proc/sys/vm/swappiness) and add “vm.swappiness = 0″ to /etc/sysctl.conf to preserve the setting after reboot and the problem is gone.
you dont have to reboot after you put the new setting in /etc/sysctl.conf. all you need to do is execute sysctl -p
Ah, if only it were that simple. In many cases I have seen Linux “helpfully” allocate swap even with swappiness set to 0.
Pingback: Big DBA Head! - Database Brain Power! » The 5 minute DBA: Default My.cnf File