Linux must know will be --vmstat

Vision, pattern, heart, courage

         ---no

 

Reference: https://man.linuxde.net/vmstat

     http://www.ha97.com/4512.html

 

Meaning vmstat command to display virtual memory, it can run a report on the overall state of the process, memory, I / 0 systems.

 

grammar

vmstat option parameters

 

parameter:

 

Event interval: status refresh interval

 

Reports show the number of times: times

 

Example:

 

vmstat 1   

 

Output once every 1s

 

vmstat 1 5

 

Each time 1s output, total output of 5

 

Field Description

 

procs:

 

r: the number of processes in the run queue, this value can also determine whether you need to increase CPU

 

b: the number of waiting I / O's

 

Memory:

 

swpd: using virtual memory size, if the value is not 0. However swpd value growth of SI, SO is 0. This does not affect system performance.

 

free: free physical memory size

 

buff: a buffer memory size as

 

cache: as a cache memory size, if the value of the cache is large, indicating that the file cache at a few more, if frequently accessed files to be able to be at the cache, then the disk read IO, bi will be very small

 

swap:

 

si: switching from second write to memory size from disk into memory

 

so: writes per memory size of the swap area, transferred from the memory disk

 

Note: Memory enough time, these two values ​​are 0, when the long-term if these two values ​​is greater than 0, the system performance will be affected, disk IO and CPU resources will be consumed. Some people see free memory (free) when little or close to zero, it is considered not enough memory, and not just look at it, but also with si and so. Few if free, but the si and so few (most of the time is 0), then do not worry, the system performance will not be affected at this time.

 

I:

 

bi: number of blocks read per second

 

bo: number of blocks written per second

 

Note: when random disk reads and writes, the two larger value (e.g., exceeds 1024K), the CPU can see the value IO waiting also become large.

  

System:

 

in: the number of interrupts per second, including the clock interrupt

 

cs: the number of context switches per second

 

NOTE: The above two larger values, see CPU time consumed by the kernel will be larger.

 

CPU :( percentage)

 

us: the percentage of time a user process execution

 

When the value of us is relatively high, indicating that multi-user consumption of CPU time, but if long-term use of over 50%, then we should consider the optimization algorithm or program to accelerate.

 

sy: system kernel process execution percentage of time

 

The higher the value of the time sy: Note. Description multi-cpu system kernel resource consumption, this is not a healthy performance, should examine the reasons.

 

wa: IO wait time percentage

 

Wa high value, indicating IO wait more serious, which can be caused by a large number of disks for random access, there may be a disk bottleneck (block operation)

 

id: idle time percentage 

 

to sum up:

Currently speaking, there are useful for server monitoring metrics are:

r (run queue)
PI (introduction page)
US (user the CPU)
SY (the CPU system)
id (idle)
Note: If r often greater than 4, often less than 40 and id, denotes the cpu load is heavy. If bi, bo long-term is not equal to 0, indicating insufficient memory.

By identifying VMSTAT CPU bottleneck:
r (run queue) shows the number of tasks being executed and waiting for CPU resources. When this value exceeds the number of CPU, there will be a CPU bottleneck.

Linux command to view the number of CPU cores under:
cat /proc/cpuinfo|grep processor|wc -l

When the r value exceeds the number of CPU, CPU bottleneck occurs, the solution generally categories:

1. The simplest is to increase the number and the CPU core number
2. By adjusting the task execution time, such as large task into the system is not busy situation for execution, Seoul balance into the system tray
3. Adjust the existing task's priority

By identifying vmstat CPU full load:

First we need to make it clear that the measure is the percentage of the CPU vmstat of. When us + sy value close to 100 when the CPU is approaching represents full capacity. But it should be noted that, CPU working at full capacity and can not explain what, Linux always try to be as busy CPU, making the task of maximizing throughput. The only way to determine CPU bottlenecks or R & lt value (run queue) a.

Vmstat RAM by identifying bottlenecks:

Database servers are only limited RAM, memory contention appears Oracle's FAQ.

First, the amount of RAM used free see:
[Oracle @ Oracle-DB02 ~] $ free
Total Used free Shared buffers cached
Mem: 2,074,924 0 2071112 3812 40616 1598656
- / + buffers / Cache: 431.84 thousand 1,643,084
Swap: 3,068,404 195804 2.8726 million

When the amount of RAM memory demand is greater than, the server starts a virtual memory mechanism, virtual memory, RAM segment can be moved to a special section SWAP DISK disk, so there will be virtual memory page export and page import phenomenon, and export the page can not explain the RAM bottleneck, virtual memory systems often have memory segments exported page, but the page will show the import server needs more memory, the page needs to import back to RAM SWAP DISK will be copied from the memory segment, resulting in server speed change slow.

There are several ways to solve:

1. The most simple increase RAM;
2. the SGA piecemeal, such that the demand for reducing the RAM;
3. demand reduction RAM. (Eg: reduction PGA)

If the disk is often not equal to 0, and b is in the queue is greater than 3, io represents poor performance.

1) If the running processes in sequence (process r) is continuously greater than the CPU in the system represents the number of the system is now running more slowly, a majority of processes waiting CPU.

2.) If the number of output r of more than 4 times the number of available CPU system, then the system CPU problem facing a shortage or a low rate of the CPU, the system waits for a majority of the CPU process, resulting in the system the process is running too slow.

3.) If the idle time (cpu id) continued to zero and the system time (cpu sy) is twice the user time (cpu us) systems are faced with a shortage of CPU resources.

Solution:

When these problems occur, please adjust the application of the CPU occupancy. Allows the application to more efficient use of CPU. At the same time consider adding more CPU. On CPU usage can also be combined mpstat, ps aux top prstat -a so some of the appropriate commands to consider regarding the use of a specific CPU, and those processes consume a lot of CPU time. under normal circumstances, the question of the application will be relatively large number, such as some of the sql statement unreasonable and so on It will cause such a phenomenon.

Memory Problems phenomenon:

Memory bottleneck is .scan rate by the scan rate (sr) is carried out to determine the page scanning algorithm by always per second. If the scan rate (sr) is greater than 200 per second continuously indicates the presence of possible defects in the memory. Also If the page entry of both pi and po columns indicate the number of pages per second transferred to the page and bring up the pages per second. If the value is often a non-zero value, it is also possible bottlenecks of memory, of course, if when the individual is not 0, then the page is a normal scheduling this is the main principle of virtual memory.

Solution:
1. Adjust applications & servers makes use of cache memory and more effective.

2. Increase the memory system.

3. Implement priority paging in s in pre solaris 8 versions by adding line “set priority paging=1” in /etc/system. Remove this line if upgrading from Solaris 7 to 8 & retaining old /etc/system file.

About memory usage may also bear ps aux top prstat -a so some of the appropriate commands to consider with regard to the specific memory usage, and those processes consume a lot of memory. In general, if the memory usage comparison high, however, very low CPU occupancy, they can consider there are many applications that take up memory is not released, however, it did not take up CPU time, consider an application for CPU time and some of the background unoccupied program, release the memory occupied.

 

Guess you like

Origin www.cnblogs.com/richered/p/11524952.html