Linux server hard disk IO read and write load high source location source location high IO load source location

First, use the top command to view  
 
1
2
3
4
5
top - 16:15:05 up 6 days,  6:25,  2 users,  load average: 1.45, 1.77, 2.14
  Tasks: 147 total,   1 running, 146 sleeping,   0 stopped,   0 zombie
  Cpu (s): 0.2% us, 0.2% sy, 0.0% ni, 86.9% id, 12.6% wa, 0.0% hi, 0.0% si
  Mem:   4037872k total,  4003648k used,    34224k free,     5512k buffers
  Swap:  7164948k total,   629192k used,  6535756k free,  3511184k cached
 
  View 12.6% wa (referring to the time the CPU waits for the disk write to complete)
  The percentage of CPU time occupied by IO waiting. When it is higher than 30%, the IO pressure is high
  Second, use iostat -x 1 10 (-x option will be used to display extended data related to io; 1 means interval; 10 means time)
  If iostat is not available, yum install sysstat  
 
1
2
3
4
5
6
avg-cpu:  %user   %nice    %sys %iowait   %idle
  0.00       0.00     0.25    33.46    66.29
  Device:    rrqm/s  wrqm/s   r/s    w/s     rsec/s   wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
  sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
  sdb          0.00   1122  17.00  9.00  192.00 9216.00    96.00  4608.00   123.79   137.23 1033.43  13.17 100.10
  sdc          0.00    0.00     0.00   0.00     0.00     0.00      0.00     0.00     0.00             0.00    0.00      0.00   0.00
 
  View %util 100.10 %idle 66.29
  %util: All processing IO time in the statistical time, divided by the total statistical time. For example, if the statistics interval is 1 second, the device is processing IO for 0.8 seconds and idle for 0.2 seconds, then the device's %util = 0.8/1 = 80%, so this parameter implies how busy the device is. In general, if this parameter is 100%, it means that the device is running at full capacity (of course, if it is multi-disk, even if %util is 100%, because of the concurrency capability of the disk, the disk usage may not be the bottleneck).
  If the idle is less than 70%, the IO pressure is large, and the general reading speed has more waits.
  At the same time, you can view the b parameter (the number of processes waiting for resources) in combination with vmstat  
 
1
vmstat 1

 

Location of sources with high IO load

 

Foreword:

In general operation and maintenance work, we often encounter such a scenario. The IO load of the server is very high (util in iostat), but the source process and source file of the IO load cannot be quickly located, resulting in the inability to implement corresponding strategies to solve the problem. .

This phenomenon is more common on MySQL. Before 5.6 (performance_schema provides io instrument), we can usually only guess that the high IO caused by MySQL is caused, but it is impossible to locate the load caused by which file.

For example, is ibdata flashing? Or the random read of unpopular ibd?

This article will introduce a relatively simple process for locating high IO load.

 

Tool preparation:

iotop:  http://guichaz.free.fr/iotop/

pt-ioprofile:http://www.percona.com/downloads/percona-toolkit/2.2.1/

 


 

Step1: iostat to view the IO situation

 iostat -x 1 Check the IO situation. From the figure below, we can see that the IO load of the dfa disk is relatively high. Next, we will locate the specific load source.

 


 

 Step2: iotop locates the load source process

 The essence of iotop is a python script that obtains thread IO information from proc and summarizes it.

As can be seen from the figure below, most of the IO sources come from the mysqld process. Therefore, it can be determined that the load source of dfa is the database

 

 


 

Step3 pt-ioprofile locates the load source file

 The principle of pt-ioprofile is to attach a strace process to a pid for IO analysis.

The following is a warning from the official website:

 However, it works by attaching strace to the process using ptrace(), which will make it run very slowly until strace detaches. In addition to freezing the server, there is also some risk of the process crashing or performing badly after strace detaches from it, or indeed of strace not detaching cleanly and leaving the process in a sleeping state. As a result, this should be considered an intrusive tool, and should not be used on production servers unless you are comfortable with that.

Use ps aux|grep mysqld to find the process number corresponding to the mysqld process, and use pt-ioprofile to check which file takes the most IO time.

By default, the tool displays the time occupied by IO.

 

 More useful for localization problems is to locate by IO throughput. Use the parameter --cell=sizes, which displays the result in B/s

 

As can be seen from the above figure, the main source of IO load is sbtest (sysbench's IO bound OLTP test).

And the pressure is mostly on reading.

Foreword:

In general operation and maintenance work, we often encounter such a scenario. The IO load of the server is very high (util in iostat), but the source process and source file of the IO load cannot be quickly located, resulting in the inability to implement corresponding strategies to solve the problem. .

This phenomenon is more common on MySQL. Before 5.6 (performance_schema provides io instrument), we can usually only guess that the high IO caused by MySQL is caused, but it is impossible to locate the load caused by which file.

For example, is ibdata flashing? Or the random read of unpopular ibd?

This article will introduce a relatively simple process for locating high IO load.

 

Tool preparation:

iotop:  http://guichaz.free.fr/iotop/

pt-ioprofile:http://www.percona.com/downloads/percona-toolkit/2.2.1/

 


 

Step1: iostat to view the IO situation

 iostat -x 1 Check the IO situation. From the figure below, we can see that the IO load of the dfa disk is relatively high. Next, we will locate the specific load source.

 


 

 Step2: iotop locates the load source process

 The essence of iotop is a python script that obtains thread IO information from proc and summarizes it.

As can be seen from the figure below, most of the IO sources come from the mysqld process. Therefore, it can be determined that the load source of dfa is the database

 

 


 

Step3 pt-ioprofile locates the load source file

 The principle of pt-ioprofile is to attach a strace process to a pid for IO analysis.

The following is a warning from the official website:

 However, it works by attaching strace to the process using ptrace(), which will make it run very slowly until strace detaches. In addition to freezing the server, there is also some risk of the process crashing or performing badly after strace detaches from it, or indeed of strace not detaching cleanly and leaving the process in a sleeping state. As a result, this should be considered an intrusive tool, and should not be used on production servers unless you are comfortable with that.

Use ps aux|grep mysqld to find the process number corresponding to the mysqld process, and use pt-ioprofile to check which file takes the most IO time.

By default, the tool displays the time occupied by IO.

 

 More useful for localization problems is to locate by IO throughput. Use the parameter --cell=sizes, which displays the result in B/s

 

As can be seen from the above figure, the main source of IO load is sbtest (sysbench's IO bound OLTP test).

And the pressure is mostly on reading.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325570838&siteId=291194637