Home Database Mysql Tutorial MySQL 调优基础(三) Linux文件系统_MySQL

MySQL 调优基础(三) Linux文件系统_MySQL

May 30, 2016 pm 05:10 PM
Base document system

Linux的文件系统有点像MySQL的存储引擎,它支持各种各样的文件系统。它最上层是通过 virtual files system虚拟文件系统作为一个抽象接口层来对外提供调用的。然后下层的各种文件系统实现这些调用接口就行了。

 

1. Linux 中的 日志文件系统和非日志文件系统

 

文件内容的修改涉及到两部分:实际文件内容的修改 和 文件元(metadata)信息的修改。所以在修改一个成功之后,修改另一个之前,此时系统崩溃,就会导致两者的不一致。所以提出了日志文件系统的概念。

 

所谓的日志文件系统(Journaling file system),就是在实际修改文件内容和文件元信息之前,将他们的修改先写到一个日志中(journal log)。这样的话,如果发生系统崩溃,就可以使用日志进行恢复。当然,写日志会对文件系统的性能有一定的影响。除了ext2之外,其它文件系统几乎都是日志文件系统。

 

日志文件系统的处理过程是:1)先写日志;2)然后写实际的文件系统;3)删除日志;

 

日志文件系统又可以分成三种类型:

 

1)日志模式(journal): 将所有的元数据和数据改变均写入日志,对性能影响最大;

 

2)预定模式(ordered): 只记录元数据的变化, 在数据写入磁盘后再修改元数据,对性能影响中等;

 

3)写回模式(writeback): 只记录元数据的修改变化,对数据修改顺序无要求,对性能影响最小;

 

我们可以在/etc/fstab 文件中修改文件系统的日志模式。

 

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

 

Linux 常用文件系统:

 

ext4, ext4, XFS, ReiserFS, JFS

 

其中最常用的是 ext4, XFS. 其中redhat7/centos7将XFS作为默认的文件系统。在最新内核的测试中XFS性能也明显超过ext4。所以对于mysql服务器,最好选择使用 XFS 文件系统。

 

关于 ssd上的ext4和xfs有一个比较:

 

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

 

在rhel6.4之前ext4性能比xfs好,因为xfs有lock争用的bug。但是6.4开始,xfs的bug被fix了。所以xfs性能比ext4好。

 

在xfs的锁争用bug没有解决时:

 

    sync                      async
threads throughput            throughput
      XFS         ext4        XFS         ext4
1    1.90/124k   1.41/92k     1.72/112k   1.41/92k
2    1.01/64k    1.65/108k    0.97/62k    1.65/108k
4    0.27/17k    1.55/102k    0.21/13k    1.55/102k
8    0.13/8k     1.45/95k     0.15/9k     1.45/95k
16   0.12/7k     1.45/95k     0.12/7k     1.45/95k 
Copy after login

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.

但是当xfs的锁争用bug解决之后:

    sync                      async
threads throughput            throughput
     vanilla     patched      vanilla      patched
1    1.90/124k   1.83/120k    1.72/112k   1.69/111k
2    1.01/64k    2.85/185k    0.97/62k    2.57/168k
4    0.27/17k    3.68/241k    0.21/13k    3.41/223k
8    0.13/8k     4.42/290k    0.15/9k     4.16/273k
16   0.12/7k     4.95/325k    0.12/7k     4.86/319k
Copy after login

 

 

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。

 

挂在文件时的优化(noatime,nodiratime):

 

mount –t ext4 –o rw,noatime,nodiratime /dev/sda6 /data

 

noatime 会有0-10%的性能提升,一般平均会有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,nodiratime的配置也可以在/etc/fstab中进行。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CUDA's universal matrix multiplication: from entry to proficiency! CUDA's universal matrix multiplication: from entry to proficiency! Mar 25, 2024 pm 12:30 PM

General Matrix Multiplication (GEMM) is a vital part of many applications and algorithms, and is also one of the important indicators for evaluating computer hardware performance. In-depth research and optimization of the implementation of GEMM can help us better understand high-performance computing and the relationship between software and hardware systems. In computer science, effective optimization of GEMM can increase computing speed and save resources, which is crucial to improving the overall performance of a computer system. An in-depth understanding of the working principle and optimization method of GEMM will help us better utilize the potential of modern computing hardware and provide more efficient solutions for various complex computing tasks. By optimizing the performance of GEMM

Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Jul 30, 2024 pm 02:17 PM

On July 29, at the roll-off ceremony of AITO Wenjie's 400,000th new car, Yu Chengdong, Huawei's Managing Director, Chairman of Terminal BG, and Chairman of Smart Car Solutions BU, attended and delivered a speech and announced that Wenjie series models will be launched this year In August, Huawei Qiankun ADS 3.0 version was launched, and it is planned to successively push upgrades from August to September. The Xiangjie S9, which will be released on August 6, will debut Huawei’s ADS3.0 intelligent driving system. With the assistance of lidar, Huawei Qiankun ADS3.0 version will greatly improve its intelligent driving capabilities, have end-to-end integrated capabilities, and adopt a new end-to-end architecture of GOD (general obstacle identification)/PDP (predictive decision-making and control) , providing the NCA function of smart driving from parking space to parking space, and upgrading CAS3.0

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box "Error 0x80004005: Unspecified Error" will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? Mar 14, 2024 pm 02:07 PM

Quark Netdisk and Baidu Netdisk are currently the most commonly used Netdisk software for storing files. If you want to save the files in Quark Netdisk to Baidu Netdisk, how do you do it? In this issue, the editor has compiled the tutorial steps for transferring files from Quark Network Disk computer to Baidu Network Disk. Let’s take a look at how to operate it. How to save Quark network disk files to Baidu network disk? To transfer files from Quark Network Disk to Baidu Network Disk, you first need to download the required files from Quark Network Disk, then select the target folder in the Baidu Network Disk client and open it. Then, drag and drop the files downloaded from Quark Cloud Disk into the folder opened by the Baidu Cloud Disk client, or use the upload function to add the files to Baidu Cloud Disk. Make sure to check whether the file was successfully transferred in Baidu Cloud Disk after the upload is completed. That's it

What is hiberfil.sys file? Can hiberfil.sys be deleted? What is hiberfil.sys file? Can hiberfil.sys be deleted? Mar 15, 2024 am 09:49 AM

Recently, many netizens have asked the editor, what is the file hiberfil.sys? Can hiberfil.sys take up a lot of C drive space and be deleted? The editor can tell you that the hiberfil.sys file can be deleted. Let’s take a look at the details below. hiberfil.sys is a hidden file in the Windows system and also a system hibernation file. It is usually stored in the root directory of the C drive, and its size is equivalent to the size of the system's installed memory. This file is used when the computer is hibernated and contains the memory data of the current system so that it can be quickly restored to the previous state during recovery. Since its size is equal to the memory capacity, it may take up a larger amount of hard drive space. hiber

Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Jun 02, 2024 pm 02:58 PM

On April 11, Huawei officially announced the HarmonyOS 4.2 100-machine upgrade plan for the first time. This time, more than 180 devices will participate in the upgrade, covering mobile phones, tablets, watches, headphones, smart screens and other devices. In the past month, with the steady progress of the HarmonyOS4.2 100-machine upgrade plan, many popular models including Huawei Pocket2, Huawei MateX5 series, nova12 series, Huawei Pura series, etc. have also started to upgrade and adapt, which means that there will be More Huawei model users can enjoy the common and often new experience brought by HarmonyOS. Judging from user feedback, the experience of Huawei Mate60 series models has improved in all aspects after upgrading HarmonyOS4.2. Especially Huawei M

Which version of Apple 16 system is the best? Which version of Apple 16 system is the best? Mar 08, 2024 pm 05:16 PM

The best version of the Apple 16 system is iOS16.1.4. The best version of the iOS16 system may vary from person to person. The additions and improvements in daily use experience have also been praised by many users. Which version of the Apple 16 system is the best? Answer: iOS16.1.4 The best version of the iOS 16 system may vary from person to person. According to public information, iOS16, launched in 2022, is considered a very stable and performant version, and users are quite satisfied with its overall experience. In addition, the addition of new features and improvements in daily use experience in iOS16 have also been well received by many users. Especially in terms of updated battery life, signal performance and heating control, user feedback has been relatively positive. However, considering iPhone14

Detailed explanation of the role of .ibd files in MySQL and related precautions Detailed explanation of the role of .ibd files in MySQL and related precautions Mar 15, 2024 am 08:00 AM

Detailed explanation of the role of .ibd files in MySQL and related precautions MySQL is a popular relational database management system, and the data in the database is stored in different files. Among them, the .ibd file is a data file in the InnoDB storage engine, used to store data and indexes in tables. This article will provide a detailed analysis of the role of the .ibd file in MySQL and provide relevant code examples to help readers better understand. 1. The role of .ibd files: storing data: .ibd files are InnoDB storage

See all articles