Phenomenon:
Information Center Room A Linux server is running slowly, the system service intermittent stop response, found that the physical memory of this server is 16G,
When the initial installation, the system management staff only allocated 2G of virtual memory. View memory usage, physical memory is not completely exhausted,
But the virtual memory is exhausted and the entire system CPU load and disk IO are very high.
Problem:
is due to the lack of swap partition, then the solution is: the virtual memory through the virtual file to 8G, the system health significantly improved.
In fact, virtual memory is not until the physical memory ran out of use, whether to use or not to use swap, in the kernel space has a parameter control.
[Root@server ~]# cat/proc/sys/vm/swappiness
60
Swappiness=0 indicates the maximum use of physical memory, then the swap space, swappiness=100 when the active use of the swap partition,
and carry the memory data into the swap space in a timely manner.
What is the appropriate swap partition for Linux systems? To do this, refer to a section of the official Library of Red Hat for an analysis of the text.
At present, Red Hat official recommends that the size of the swap partition be linearly proportional to the size of the system's physical memory.
However, in systems less than 2GB of physical memory, the swap partition size should be set to twice times the size of memory, and if the memory size is greater than 2GB, the swap partition size should be the physical memory size plus 2GB.
The reason for this is that the larger the physical memory in the system, the greater the load on memory may be.
In general, swap sizes can be set according to the following rules:
Within 4G of physical memory, SWAP is set to twice times the memory.
4-8g physical memory, SWAP equals memory size.
8-64G physical memory, SWAP set to 8G.
64-256g physical memory, SWAP set to 16G.
Physical Memory Swap partition
Less than or equal to 4G at least 2G
4~16g at least 4G
16~64G at least 8G
64~256g at least 16G
Whether to adjust the swap size basis