View the system's I/O, use the iostat command, and use iotop to sort by I/O statistics and track specific processes.
When I/O wait time accounts for a high percentage of CPU time, you must first check whether the machine is using a large amount of swap space, because the hard disk operation speed is much lower than that of RAM, therefore, when the system memory is exhausted and the swap space is used up, the system performance will be seriously affected. Any operation that you want to access the hard disk must complete I/O switching with the hard disk. Therefore, the first step in troubleshooting is to check whether the memory is exhausted. If yes, solve the problem first. If there is a large amount of available RAM, you need to make sure that the process occupies most of the I/O operations.
It is hard to figure out which process occupies a large amount of I/O resources. You can use iostat to find which partition performs a large number of I/O operations.
Iostat usage
The top display is a cpu, 64-bit system, and Linux kernel version.
Avg-cpu segment:
% User: Percentage of CPU used for running at the user level
% Nice: Percentage of CPU used by nice operations
% System: Percentage of CPU used to run at the system level (kernel)
% Iowait: CPU usage when the CPU waits for hardware I/O
% Idle: Percentage of CPU idle time
Device segment:
Sda: Device Name
Tps: the number of I/O requests sent per second.
Blk_read/s: volume of data read per second
Blk_wrtn/s: the volume of data written per second.
Blk_read: total data volume read
Blk_wrtn: total data volume written
Parameters of iostat:
-C only displays CPU statistics. It is mutually exclusive with the-d option.
-D only displays the disk statistics. It is mutually exclusive with the-c option.
-K indicates the number of disk requests per second in K. The default unit is block.
-P device "ALL
This parameter is mutually exclusive with the-x option. It is used to display the statistics of Block devices and system partitions. You can also specify a device name after-p, for example:
# Iostat-p hda
Or display all devices
# Iostat-p ALL
-T print the data collection time when outputting data.
-V: print the version number and help information.
-X output extension information.
Add a number after iostat.
Iostat 4 indicates refreshing every 4 seconds.
Iotop usage
Programming is useful.
-T, -- time plus timestamp, non-interactive non-mode.
-Q, -- quiet disables the first few rows in non-interactive mode. You can specify three methods.
-Q: only the column names are displayed during the first monitoring.
-Qq never displays the column name.
-Qqq never displays I/O summary.