An incomplete guide to linux system configuration for MySQL
As a former Oracle DBA, I know how the system and the database are linked.
The first one who told me that the installation of Oracle has never been a problem is a liar!
Yes, your database and your system are the best of friends, you must respect that.
I’d make a list of linux system settings to configure a MySQL databases server and share my sources with you.
In return, I would like you to share your sources with the community by publishing your tips in the comments.
- This parameter allows to specify how the kernel must manage the memory swap
- Default value : 60 (Range 0 to 100)
- Value to set : 0 (it will swap only to avoid an out of memory condition)
- How to set a new non-persistent value : sysctl -w vm.swappiness=0
- How to store a new persistent value : add vm.swappiness=0 in the /etc/sysctl.conf file
- The I/O scheduler manages and optimizes priorities of I/O requests
- Default value : device driver dependent
- Range of values : noop / deadline / anticipatory / cfq
- Value to set : noop
- How to set a new persistent value : echo noop >/sys/block/[DEVICE]/queue/scheduler
- These options are set during the filesystem mount process
- Default value : rw
- Value to set ext4 : rw,nosuid,noatime,data=ordered
- Value to set xfs : nobarrier
- How to store a new persistent value : add these options in the /etc/fstab file
I/O queue size
- This queue stores incoming I/O requests
- Default value : 128 (No range)
- Value to set : Hey Dude, you have to test, no magic value for this parameter
- How to set a new persistent value : echo 100000 > /sys/block/[DEVICE]/queue/nr_requests
- These settings are used to tune the VM subsystem about dirty data
- Default value : 10 and 20
- Value to set : Again, you should test. You can try 5 and 60 to begin
- How to set a new non-persistent value :
- echo 5 > /proc/sys/vm/dirty_background_ratio
- echo 60 > /proc/sys/vm/dirty_ratio
- How to store a new persistent value : Add these parameters to the /etc/sysctl.conf file
- vm.dirty_background_ratio = 5
- vm.dirty_ratio = 60
- Memory allocation management for multiple processors architecture
- You should read this : http://blog.jcole.us/2010/09/28/mysql-swap-insanity-and-the-numa-architecture/
- And test…
Note that all of these tips focus on optimizing I/O.
The first three tips can be considered as really interesting.
I recommend you to read the sources before any change.
Remember to test every changes before to put them in production.
Now, let us know how you setup your system for MySQL.