12. Choosing Right MySQL Filesystem
Choosing the right filesystem is vital for your databases. Most important things you need to consider here are – data integrity, performance and ease of administration.
As per MariaDB’s recommendations, the best file systems are XFS, Ext4 and Btrfs. All of them are enterprise journaling filesystems that can be used with very large files and large storage volumes.
Below you can find some useful information about the three filesystems:
Filesystems | XFS | Ext4 | Btrfs |
Maximum filesystem size | 8EB | 1EB | 16EB |
Maximum file size | 8EB | 16TB | 16EB |
The pros and cons of the Linux filesystems have been extensively covered in our article:
13. Set MySQL max_allowed_packet
MySQL splits data into packets. Usually a single packet is considered a row that is sent to a client. The max_allowed_packet
directive defines the maximum size of packet that can be sent.
Setting this value too low can cause a query to stall and you will receive an error in your MySQL error log. It is recommended to set the value to the size of your largest packet.
14. Check MySQL Performance Tuning
Measuring your MySQL/MariaDB performance is something that you should do on regular basis. This will help you see if something in the resource usage changes or needs to be improved.
There are plenty of tools available for benchmarking, but I would like to suggest you one that is simple and easy to use. The tool is called mysqltuner.
To download and run it, use the following set of commands:
# wget https://github.com/major/MySQLTuner-perl/tarball/master # tar xf master # cd major-MySQLTuner-perl-993bc18/ # ./mysqltuner.pl
You will receive a detailed report about your MySQL usage and recommendation tips. Here is a sample output of default MariaDB installation:
15. Optimize and Repair MySQL Databases
Sometimes MySQL/MariaDB database tables get crashed quite easily, especially when unexpected server shut down, sudden file system corruption or during copy operation, when database is still accessed. Surprisingly, there is a free open source tool called ‘mysqlcheck‘, which automatically check, repair and optimize databases of all tables in Linux.
# mysqlcheck -u root -p --auto-repair --check --optimize --all-databases # mysqlcheck -u root -p --auto-repair --check --optimize databasename
That’s it! I hope you have found the above article useful and help you tune up your MySQL server. As always if you have any further questions or comments, please submit them in the comment section below.
Read Also:
Hello ,
I got a dedicated server with the following characteristics.
On Linux server with Centos7 installs and more detailed specifications below.
The problem with this is that I do not know the correct configuration for the error problem 504 Gateway Timeout Error, and I usually have this error on sites.
Someone guides me?
What are the best settings & config for “my.cnf” “nginx.cnf” “php.ini”? Guidance if possible?
thanks .
I have been learning more and more about tuning/hardening from your website when referencing Maria/DB. Thanks for the great presentations and the easy to copy one-liners for my SSH session. Cheers!
I really appreciate your explanation and problem solving methodologies. It’s Awesome article. Thank you very much for the time and effort.
Good job!
Does not work anymore: “Error: mysqlcheck doesn’t support multiple contradicting commands.”
You will have to execute the repair and optimize separately.
Really helpful
Formatted the fs as ext4 then write fstab using ext3. Makes no sense.
“2. Store MySQL Database Data on Separate Partition Note: This setup only works with MySQL, but not with MariaDB.”
Same question as “Asd”, why? Would have been better to include that in the article.
Also, rather than link, I just mounted the second drive at “/var/lib/mysql”.
15. Optimize and Repair is applicable only for tables of myisam storage engine i think so..
At RHEL based systems you should call fdisk with “-c” to disable dos compatible mode which results in proper alignment of your disks.
Nice article :)
This seems to be incorrect/typo. Section 14 has “The tool is called musqltunner”. Should be “mysqltuner”
@Nick,
Corrected that typo….
“2. Store MySQL Database Data on Separate Partition
Note: This setup only works with MySQL, but not with MariaDB.”
Why? And why in 2015 ext3? :)
Excellent, thank you I will review it thoroughly.