Please Wait, Loading...

Thursday 16 June 2016

Penanganan "Lack of free swap space on Portal 6" On CentOS

Penanganan "Lack of free swap space on Portal 6" dapat diketahui dengan menggunakan perintah linux sebagai berikut :

[root@portal ~]# free -h
             total       used       free     shared    buffers     cached
Mem:          4.7G       4.6G        34M       328K       676K       6.6M
-/+ buffers/cache:       4.6G        41M
Swap:         1.5G       1.5G         0B


Dari perintah linux diatas diketahui bahwa swap memori 0B, solusi yang dapat dilakukan ialah dengan cara menambah ukuran memori swap.

Berikut langkah-langkah dalam menambah memori swap di Linux CentOS :

  1. [root@portal1 ~]# swapon -s
    Filename                                Type            Size    Used    Priority
    /dev/dm-1                               partition       1572860 1572860 -1
  2. [root@portal1 ~]# free -h
                 total       used       free     shared    buffers     cached
    Mem:          4.7G       4.6G        29M       328K       632K       6.2M
    -/+ buffers/cache:       4.6G        36M
    Swap:         1.5G       1.5G         0B
  3. [root@portal1 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           13G  1.3G   11G  11% /
    tmpfs                 3.0G     0  3.0G   0% /dev/shm
    /dev/xvda1            477M   57M  395M  13% /boot
    10.10.102.1:/mnt/data/vhost
                          527G  287G  240G  55% /etc/httpd/conf/vhost
    10.10.102.1:/mnt/data/php_session
                          527G  287G  240G  55% /var/lib/php/session
    10.10.102.1:/mnt/data/website
  4. [root@portal1 ~]# ls -lh /swapfile
    ls: cannot access /swapfile: No such file or directory
  5. [root@portal1 /]# sudo fallocate -l 4G /swapfile
  6. [root@portal1 /]# ls -lh /swapfile
    -rw-r--r-- 1 root root 4.0G Jun 16 14:41 /swapfile
  7. [root@portal1 /]# sudo chmod 600 /swapfile
  8. [root@portal1 /]# ls -lh /swapfile
    -rw------- 1 root root 4.0G Jun 16 14:41 /swapfile
  9. [root@portal1 /]# sudo chmod 600 /swapfile
  10. [root@portal1 /]# ls -lh /swapfile
    -rw------- 1 root root 4.0G Jun 16 14:41 /swapfile
  11. [root@portal1 /]# sudo mkswap -f /swapfile
    Setting up swapspace version 1, size = 4194300 KiB
    no label, UUID=fd44055f-0713-458a-9e7b-6beaf2b5f044
  12. [root@portal1 /]# swapon /swapfile
  13. [root@portal1 /]# swapon -s
    Filename                                Type            Size    Used    Priority
    /dev/dm-1                               partition       1572860 1572860 -1
    /swapfile                               file            4194300 14808   -2
  14. [root@portal1 /]# free -m
                 total       used       free     shared    buffers     cached
    Mem:          4787       4760         26          0          0         12
    -/+ buffers/cache:       4748         39
    Swap:         5631       1551       4080
  15. Buat agar OS  secara otomatis akan menggunakan swap file
    /swapfile  swap  swap    sw  0 0 

Demikian Semoga Bermanfaat..