2018-08-07

Memory swapping on Linux

Environment
Oracle Linux 7 with Oracle databases 12.1

Monitoring
free -h
top
vmstat [options] [delay [count]]

monitoring a particular process
ps -o "ppid pid vsz rss pmem comm args" --pid
top -p  
pmap -x

adding SWAP to top and changing SORT column
a. Run the TOP command:
# top
b. On your keyboard press the " f " key and scroll down using the arrow key until you have selected "SWAP" then press to select it. This should add a " * " symbol in front of it.
c. While still selecting "SWAP"  press the arrow key, which highlights the entire SWAP line, and using the arrow key move it up to one of the first options (anywhere above "COMMAND").
d. While still having "SWAP" selected, type the " s " key which will configure top to SORT by the currently selected option, in this case SWAP.
e. Finally " q " to save the configuration changes and view the results.
f. Perform your review as needed and press "q" again to exit top command.
g. If you want to save this top configuration press W (upper case)

Kernel parameters and tuned service
check the current parameters
sysctl -a|grep 'dirty\|swap'

check status of tuned.service, it overwrites parameters in /etc/sysctl.conf !
systemctl status tuned.service

Check the active tune profile. 
tuned-adm active
Current active profile: virtual-guest
see all profiles
cd /usr/lib/tuned
ls -lh
For example, modify the current profile
cd /usr/lib/tuned/virtual-guest
vi tuned.conf
comment existing vm.* parameters and add the following
# recommended by RedHat. Deploying Oracle Database 12c Release 2 on Red Hat Enterprise Linux 7.
vm.swappiness = 1
vm.dirty_background_ratio = 3
vm.dirty_ratio = 80
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100

re-activate the changed profile
tuned-adm profile virtual-guest
show the current kernel parameters
sysctl -a|grep 'dirty\|swap'

MOSC Documentation
Linux OS, Swapping and Databases (Doc ID 1295478.1)
How to Check Swap Usage Live via the 'top' Command on Oracle Linux 5, 6, and 7. (Doc ID 2422888.1)
Why is SWAP being used instead of available physical memory? (Doc ID 2404462.1)
Oracle Linux 7 - sysctl parameter doesn't take effect after reboot (Doc ID 2195319.1)
Oracle Linux: Modifying kernel parameters using sysctl (Doc ID 390279.1)
What are Dirty Pages? (Doc ID 2304722.1)

RedHat Documentation


No comments:

Post a comment