MySQL tuning basics (III) Linux file system _ MySQL-mysql tutorial

Source: Internet
Author: User
The Linux file system is a bit like the MySQL storage engine, which supports a variety of file systems. At the top of the interface, the virtualfilessystem virtual file system acts as an abstract interface layer to provide external calls. Then the underlying file systems implement these calling interfaces. The Linux file system is a bit like the MySQL storage engine, which supports a variety of file systems. The top layer of the virtual file system provides external calls through the virtual file system as an abstract interface layer. Then, all the file systems in the lower layer can implement these called interfaces.

1. log file system and non-Log File System in Linux

The modification of the file content involves the modification of the actual file content and the modification of the metadata information. Therefore, after a successful modification and before another modification, the system crashes, causing inconsistency between the two. Therefore, the concept of a log file system is proposed.

The so-called Journaling file system is to write the modifications to a log before actually modifying the file content and object metadata ). In this case, you can use logs to recover the system from a system crash. Of course, writing logs may affect the file system performance. Except ext2, almost all other file systems are log file systems.

The processing process of the log file system is: 1) first write the log; 2) then write the actual file system; 3) delete the log;

Log file systems can be divided into three types:

1) log mode (journal): writes all metadata and data changes to the log, with the greatest impact on performance;

2) subscription mode (ordered): only changes in metadata are recorded, and metadata is modified after data is written to the disk, which has moderate impact on performance;

3) write-back mode (writeback): only changes in metadata are recorded, with no requirements on the data modification sequence and minimum impact on performance;

You can modify the log mode of the file system in the/etc/fstab file.

/Dev/sdb1/testfs ext3 defaults, data = writeback 0 0

Common Linux File Systems:

Ext4, ext4, XFS, ReiserFS, JFS

The most common one is ext4, XFS. redhat7/centos7 uses XFS as the default file system. In the latest kernel test, XFS performance also significantly exceeds ext4. Therefore, we recommend that you use the XFS file system for the mysql server.

There is a comparison between ext4 and xfs on ssd:

Https://www.percona.com/blog/2012/03/15/ext4-vs-xfs-on-ssd/

Before rhel6.4, ext4 had better performance than xfs because xfs had a lock contention bug. But at the beginning of 6.4, the xfs bug was fixed. Therefore, xfs has better performance than ext4.

When the xfs lock contention bug is not resolved:

    sync                      asyncthreads throughput            throughput      XFS         ext4        XFS         ext41    1.90/124k   1.41/92k     1.72/112k   1.41/92k2    1.01/64k    1.65/108k    0.97/62k    1.65/108k4    0.27/17k    1.55/102k    0.21/13k    1.55/102k8    0.13/8k     1.45/95k     0.15/9k     1.45/95k16   0.12/7k     1.45/95k     0.12/7k     1.45/95k 

It's pretty clear from these results that lock contention is killing XFS as the thread count grows. ext4 performance shows that it uses exclusive locking as well, but it is not degrading like XFS is due to different lock types being used.

However, after the xfs lock contention bug is resolved:

    sync                      asyncthreads throughput            throughput     vanilla     patched      vanilla      patched1    1.90/124k   1.83/120k    1.72/112k   1.69/111k2    1.01/64k    2.85/185k    0.97/62k    2.57/168k4    0.27/17k    3.68/241k    0.21/13k    3.41/223k8    0.13/8k     4.42/290k    0.15/9k     4.16/273k16   0.12/7k     4.95/325k    0.12/7k     4.86/319k

Throughput scales with thread count-each thread runs at 100% CPU utilsation, and XFS gets up to 3x as much throughput as ext4 does. so, basically, XFS is still the file system you want for direct IO.

Optimization of hanging files (noatime, nodiratime ):

Mount-t ext4-o rw, noatime, nodiratime/dev/sda6/data

Noatime has a performance improvement of 0-10%, and generally has an average performance improvement of 3%.

Noatime:

Do not update inode access times on this filesystem (e. g, for faster access on the news spool to speed up news servers ).

Nodiratime:

Do not update directory inode access times on this filesystem.

Noatime and nodiratime can be configured in/etc/fstab.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.