The tech blog uses a Aliyun server, the lowest-configured type (only 512M of RAM). When installing the latest version of MARIADB, it always fails to install because of insufficient memory. So tech decided to turn on swap.
Since opening swap reduces disk IO performance, it can be removed after use.
1. Create an interchange partition file
DD If=/dev/zero Of=/home/swap bs=1m count=512
qq20160115-0
The size of the Bs:block,
The number of Count:block can be customized.
/home/swap: Technical Ann Custom swap file location
It's a 512M swap, technically.
2, set the swap file
Mkswap/home/swap
Qq20160115-1
3. Enable Swap Now
Swapon/home/swap
Qq20160115-2
If there are swapoff-a in the/etc/rc.local that need to be modified into swapon-a
4, according to the need can set whether to boot
echo '/home/swap swap defaults 0 0 ' >>/etc/fstab
5. View Swap
Free-m
Classic Case ECS Linux open swap (virtual memory)
1, creating a file for swap partitions
#dd if=/dev/zero of=/mnt/swap bs=block_size count=number_of_block /div>
Note: block_size, number_of_block size can be customized, such as bs=1m count=1024 to set 1G size swap partition
2, set swap partition file
#mkswap/mnt/swap
PS://IMG.ALICDN.COM/TFSCOM/TB16MSYHXXXXXBXXVX Xxxxxxxxx.jpg "/>
3, immediately enable the swap partition file
#swapon/mnt/swap
if in/e Tc/rc.local swapoff-a needs to be modified to swapon-a
4, setting auto-enable swap at power-on The partition
requires to modify the swap line in the file/etc/fstab.
Add/mnt/swap swap defaults 0 0
Note:/mnt/swap path can be modified, depending on the created swap file Diameter to configure.
settings can perform free-m command view effect