Wednesday, 30 May 2012

Solaris - Changing the swap size (ZFS)

One of our servers was running out of space and we knew that for some reason the company that came in and JumpStarted all our new hardware had set the swap space to 64Gb.

All the servers are running ZFS so I thought if I reduced the size of rpool/swap then that would free up space for use in the rpool.

Next step was what should the size be?
1. I had read that you should make the swap space 30% of total RAM.
2. The Business wanted to purchase some more RAM for the box in the near future.

I played safe and would set the swap space to 16Gb (I could reduce it again later if need be)

To check how much RAM is in your machine:

# prtconf | grep "Memory size"

To check if the swap file is in use:

# swap -l

Delete the existing swap (if the swap file isn't in use)

# swap -d /dev/zvol/dsk/rpool/swap

To set the swap area to 16Gb:

# zfs set volsize=16384m rpool/swap

To activate the changed swap:

# swap -a /dev/zvol/dsk/rpool/swap

To check the change:
# zfs list

On one server this worked perfectly well, on another the zfs list didn't change the used size (I then changed the swap size to 14G and now it won't change back!!) - further investigation required.

NAME         USED  AVAIL  REFER  MOUNTPOINT
rpool/swap  66.0G     59.0G     14.1G          -


Then I looked at the file system to check the configuration:

# df -h /tmp

It read a different size to what was set in the ZFS rpool - So I read a bit more and found that you could limit the swap in the /etc/vfstab file. Armed with this information I edited the vfstab file - which requires a reboot for the changes to take effect:

# vi /etc/vfstab

The /etc/vfstab file should look something like this:

swap            -               /tmp            tmpfs   -       yes     size=16384m

Then reboot:

# init 6

Once the server has rebooted you can check all the settings you've just changed:

# zfs list

# df -h /tmp

# zfs get referenced,volsize,refreservation,usedbyrefreservation rpool/swap

NAME        PROPERTY              VALUE          SOURCE
rpool/swap  referenced                      16K            -
rpool/swap  volsize                            16G            local
rpool/swap  refreservation                 16.5G          local
rpool/swap  usedbyrefreservation       16.5G          -

Reference site(s):
http://docs.oracle.com/cd/E19082-01/817-2271/ggvlr/index.html
http://www.solarisinternals.com/wiki/index.php/ZFS_Troubleshooting_Guide

No comments:

Post a Comment