View swappiness value

Swap frequency of use

By adjusting the swappinessvalue, the system can be used to adjust the frequency of the swap

The smaller the value, the greater the extent of physical memory, min = 0

The larger the value, the more active the swap swap, max = 100

View swappiness value

cat /proc/sys/vm/swappiness

centos default is 10, Ubuntu default 60

Temporary modification (restart failure)

sysctl vm.swappiness=59

Permanent modification

echo "vm.swappiness=59" >> /etc/sysctl.conf

 

On / off function + SWAP SWAP to make the file / partition

Can be used in linux free -mcommand to view memory usage (including use of swap swap partition) on the meaning of existence of the swap will not be discussed, and some people in some circumstances need to open the swap function to ensure that the program does not crash; there who in some cases you need to close the swap feature to ensure that "no dang rather slow."

On / off function swap

Open

  • The swap file: swapon /opt/swapfile
  • swap partition: swapon /dev/sdb1

shut down

  • The swap file: swapoff /opt/swapfile
  • swap partition: swapoff /dev/sdb1

If the system is set up swap during the installation, at a later stage want to close swap feature, you can go to modify /etc/fstabfile

Swap information will contain this line commented out/dev/mapper/centos-swap swap swap defaults 0 0

Increase swap space

Production swap file

1
2
3
4
5
6
7
8
9
10
11
# Create a file 1G as a swap using 
➜ ~ dd IF = / dev / ZERO of = / opt / the swapfile BS = 1M COUNT = 1000

# formatted swap partition
➜ ~ the mkswap / opt / the swapfile

# open swap partition
➜ ~ swapon / opt / the swapfile

# increases as a record in / etc / fstab in
/ opt / swapfile swap swap defaults 0 0

Production swap partition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Create a swap partition 
➜ ~ the fdisk / dev / SDB # Create a new partition n- P default default ... # id to modify the partition swap T 82 # write the partition table W # partition table information and the synchronization memory ➜ the partprobe ~ # formatted swap partition ➜ ~ the mkswap / dev / sdb1 # open swap partition ➜ ~ the swapon / dev / sdb1 # increase in the / etc / fstab as a record / opt / swapfile swap swap defaults 0 0























Tips: If the machine has 2G swap swap partition, and make the swap file partition 8G, then the execution swaponafter the command, swap space for 10G (swap space will accumulate)

Guess you like

Origin www.cnblogs.com/xuanbjut/p/11488985.html