use scenes for swap
Swap has two main uses
1, when the system needs more memory space than physical memory, the kernel will use less memory inside the memory page swap out to the swap partition, to empty out the physical memory to the current should be used for fast running.
2, some applications started when the application is not used during the operation of the memory page, the system will be this part of the page also swap out to swap space to set aside the physical memory page for other applications or disk caching.
This memory management strategy for Linux is primarily designed to conserve physical memory and improve the execution speed of current applications. However, swap cannot be used as a means of expanding memory, because swap reads and writes are part of disk IO, which is much slower than physical memory Io.
If the system frequently swap out memory pages to the swap partition, and then swap in the swap partition to the memory page, which means that the system is looking for free memory to be multiple applications running at the same time, that is, the current system tasks are busy, but the available memory is not enough, The only way to do this is by increasing the physical memory.
Therefore, the measurement of a system memory consumption is to the bottleneck, you can observe the amount of swap and SI so frequency to evaluate.
The day in the virtual machine installed Oracle 11g R2, found that the default swap space does not meet the minimum requirements, because I allocated the physical memory is 1G, then the demand for 2G swap space, currently only 1G swap space.
the steps to add swap space are as follows:
Step one: Make sure there is enough space in the system for swap swap, prepare to add a swap file to a separate file system, and add 1G swap files to/tmp
Step two: Add the swap file and set its size to 1G, using the following command [root@oracle]# DD If=/dev/zero of=/tmp/swap bs=1mb count=1024
1024000+0 Records in
1024000+0 Records out
1024000000 bytes (1.0 GB) copied, 14.3745 seconds, 71.2 MB/s
Step Three: Create (set) Swap space, use command MKSWAP [root@oracle]# mkswap/tmp/swap
Mkswap:/tmp/swap:warning:don ' t erase boot bits sectors//Do not erase boot bit sector, no tube
On whole disk. Use-f to force.
Setting up Swapspace version 1, size = 999996 KiB
No label, uuid=c02cf589-0631-4623-bae6-8aa36b4c3d9b
Step Fourth: Check the existing swap space size, using the command free [root@oracle]# free-m
Total used free shared buffers Cached
mem:1287 1212 74 0 1 875
-/+ buffers/cache:318 968
swap:969 0 969
Or check the Meminfo file [root@oracle]# grep swaptotal/proc/meminfo
Step Fifth: Start the newly added 1G swap space and use the command swapon [root@oracle]# swapon/tmp/swap
Step Sixth: Confirm that the newly added 1G swap space is in effect, using the command free [[root@oracle]# free-m
Total used free shared buffers Cached
mem:1287 1212 74 0 4 877
-/+ buffers/cache:318 968
swap:1936 0 1936
Step seventh: Use Vim to modify the/etc/fstab file so that the newly added 1G swap space automatically takes effect after the system restarts
At the end of the file add:/tmp/swap Swap defaults 0 0
This is the Linux system CentOS to increase the size of the swap space, the actual operation of the dimension, often encountered. The problem is always out of date, and the accumulated experience can help you solve one problem after another. Lay the basics of Linux and start at the top of the technology class now.
--This article from: http://www.cnblogs.com/yanvcl/p/4883785.html,https://www.jishuyiliu.com/archives/209.html