quarta-feira, 20 de junho de 2018

Linux - create swap file

A note on hosting (https://packagist.org/packages/sonarsoftware/freeradius_genie)

If you're hosting this online, it's likely that your server does not have any swap memory setup. If you've selected a server with a low amount of RAM (1-2G), or even if you've picked more, it can be worthwhile setting up a swap partition to make sure you don't run into any out of memory errors. Your swap file size should be, at minimum, be equal to the amount of physical RAM on the server. It should be, at maximum, equal to 2x the amount of physical RAM on the server. A good rule of thumb is to just start by making it equal to the amount of available RAM, increasing to double the RAM if you run into out of memory errors. If you run into out of memory errors after moving to 2x the amount of RAM, you should increase the amount of RAM on your server rather than increasing swap. The SwapFaq on ubuntu.com can be helpful as well.
To setup swap, run the following commands as root (or by putting 'sudo' in front of each command):
  1. /usr/bin/fallocate -l 4G /swapfile where 4G is equal to the size of the swap file in gigabytes.
  2. /bin/chmod 600 /swapfile
  3. /sbin/mkswap /swapfile
  4. /sbin/swapon /swapfile
  5. echo "/swapfile none swap sw 0 0" >> /etc/fstab
  6. /sbin/sysctl vm.swappiness=10
  7. echo "vm.swappiness=10" >> /etc/sysctl.conf
  8. /sbin/sysctl vm.vfs_cache_pressure=50
  9. echo "vm.vfs_cache_pressure=50" >> /etc/sysctl.conf

0 comentários: