I am now using the Aliyun minimum configured server, 1 cores, 512MB memory, viewing memory information swap space is 0MB, as follows:
[root@www ~]# free-m
total used free shared buffers Cached
mem: 494 124 370 0 7
-/+ buffers/cache: 74 419
swap: 0 0 0
After searching for information, the following solutions are available in the Aliyun forum:
Source Address: http://bbs.aliyun.com/read/139905.html?spm=5176.7189909.0.0.bE6Z3x
1. Access to catalogue
cd/var/
2. Get the block of swap files to add (here in 1GB for example, Count = 1024 x 1024)
DD If=/dev/zero of=swapfile bs=1024 count=1048576
3. Create a swap file
/sbin/mkswap Swapfile
4. Activate swap file
/sbin/swapon Swapfile (now you can see the swap space with the free command)
5. See if swap information is correct
/sbin/swapon–s
6. Add to Fstab file to allow system to boot automatically when booting
echo "/var/swapfile swap defaults 0 0" >>/etc/fstab
7. Modify/etc/rc.local
Cat/etc/rc.local
Touch/var/lock/subsys/local
#swapoff-A
8. Reboot the server
Reboot
The results are as follows: