Swap may be used when there isn't enough RAM available for the running processes on a server. The following warnings are presented as swap usage increases:
Severity | Usage |
---|---|
Low | 90% of Physical Memory, 60% of Swap Memory |
Medium | 90% of Physical Memory, 70% of Swap Memory |
High | 90% of Physical Memory, 80% of Swap Memory |
Remediation
Swap memory is used by Linux over the course of normal operation, but it does not get relinquish automatically. If you are receiving these alerts often, but they seem to clear automatically, it may be due to temporary memory spikes and may be resolved by resetting swap.
To reset your swap memory, first check that you have enough available physical memory to store the swap with the command free -m
root@deskpro:/# free -m
total used free shared buff/cache available
Mem: 3931 2115 241 141 1575 1394
Swap: 3930 957 2973 copy
In the example above, 957MB of swap memory is used
, but we have 1394MB of physical memory available
.
We can now turn off swap with the command swapoff -a
, checking repeatedly with free -m
to confirm the used swap decreases to 0, and the available memory has decreased as the data is moved.
root@deskpro:/# free -m
total used free shared buff/cache available
Mem: 3931 2842 116 273 972 540
Swap: 0 0 0 copy
Finally, once the swap has cleared, you can turn it back on with the command swapon -a
, and you should see that the used swap memory is back down to 0MB:
root@deskpro:/# free -m
total used free shared buff/cache available
Mem: 3931 2839 189 273 902 543
Swap: 3930 0 3930 copy
If you continue to have issues with swap after a reset, it may be that you do not have enough memory available for your helpdesk to run optimally, and you may be required to increase the physical memory allocated to your server.
Log ind, eller opret dig for at skrive en kommentar.