Wednesday, May 16, 2012

Adding swap space on CentOS

# login as root with
su -

# not '-' sign - important!

#allocate file: 20 GB = 20 * 1024 * 1024
dd if=/dev/zero of=/swapfile bs=1024 count=20971520

mkswap /swapfile

#set permissions:
chown root:root /swapfile
chmod 0600 /swapfile

#add immediately to OS
swapon /swapfile

# edit fstab for persistence:
vi /etc/fstab

# edit fstab by adding the following line at the end of the file:
/swapfile /swap swap defaults 0 0

# check if the swap is allocated
free -m

Wednesday, May 02, 2012

Increase number of open files per user

http://prefetch.net/blog/index.php/2009/07/31/increasing-the-number-of-available-file-descriptors-on-centos-and-fedora-linux-servers


$ ulimit -n
1024

$ cat /proc/sys/fs/file-max
366207

$ echo 512000 > /proc/sys/fs/file-max

$ cat /proc/sys/fs/file-max
512000

$ vi /etc/security/limits.conf

Now add a line after @student (the last user listed)

@username   -   nofile   70000


$ ulimit -n
8192