We are running a Freeradius server on a VMware server and we have a high memory usage that I am trying to troubleshoot. We are running the PostgreSQL 8.4 as the database backend on the same server for the radius server. This issue has been discovered because we are monitoring the server with OpenNMS. We see that it is reaching his memory limit and start swapping on time to time.
This is the memory usage:
free -m
total used free shared buffers cached
Mem: 2013 1972 41 0 322 284
-/+ buffers/cache: 1364 648
Swap: 382 0 382
if I do top -d1 and I press m to sort them by memory usage:
top - 10:37:40 up 6 days, 2:20, 2 users, load average: 0.01, 0.02, 0.00
Tasks: 102 total, 1 running, 101 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.0%us, 1.0%sy, 0.0%ni, 96.1%id, 1.0%wa, 0.0%hi, 0.0%si, 0.0%st
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7914 postgres 20 0 102m 22m 21m S 1.0 1.1 0:06.44 postgres
8833 root 20 0 19064 1336 1000 R 1.0 0.1 0:00.03 top
1 root 20 0 8352 808 676 S 0.0 0.0 0:04.07 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
4 root 20 0 0 0 0 S 0.0 0.0 0:00.39 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
6 root 20 0 0 0 0 S 0.0 0.0 0:03.40 events/0
7 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuset
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 netns
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 async/mgr
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 pm
12 root 20 0 0 0 0 S 0.0 0.0 0:00.25 sync_supers
13 root 20 0 0 0 0 S 0.0 0.0 0:00.43 bdi-default
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kintegrityd/0
15 root 20 0 0 0 0 S 0.0 0.0 0:00.70 kblockd/0
HTOP revealed morre info about the processes childrens: htop picture
If I look at the processes with children, I can see that postgresql seems to be eating all the ram:
~:ps auxf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? S Nov03 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Nov03 0:00 \_ [migration/0]
root 4 0.0 0.0 0 0 ? S Nov03 0:00 \_ [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S Nov03 0:00 \_ [watchdog/0]
root 6 0.0 0.0 0 0 ? S Nov03 0:03 \_ [events/0]
root 7 0.0 0.0 0 0 ? S Nov03 0:00 \_ [cpuset]
root 8 0.0 0.0 0 0 ? S Nov03 0:00 \_ [khelper]
root 9 0.0 0.0 0 0 ? S Nov03 0:00 \_ [netns]
root 10 0.0 0.0 0 0 ? S Nov03 0:00 \_ [async/mgr]
root 11 0.0 0.0 0 0 ? S Nov03 0:00 \_ [pm]
root 12 0.0 0.0 0 0 ? S Nov03 0:00 \_ [sync_supers]
root 13 0.0 0.0 0 0 ? S Nov03 0:00 \_ [bdi-default]
root 14 0.0 0.0 0 0 ? S Nov03 0:00 \_ [kintegrityd/0]
root 15 0.0 0.0 0 0 ? S Nov03 0:00 \_ [kblockd/0]
root 16 0.0 0.0 0 0 ? S Nov03 0:00 \_ [kacpid]
root 17 0.0 0.0 0 0 ? S Nov03 0:00 \_ [kacpi_notify]
root 18 0.0 0.0 0 0 ? S Nov03 0:00 \_ [kacpi_hotplug]
root 19 0.0 0.0 0 0 ? S Nov03 0:00 \_ [kseriod]
root 21 0.0 0.0 0 0 ? S Nov03 0:00 \_ [kondemand/0]
root 22 0.0 0.0 0 0 ? S Nov03 0:00 \_ [khungtaskd]
root 23 0.0 0.0 0 0 ? S Nov03 0:00 \_ [kswapd0]
root 24 0.0 0.0 0 0 ? SN Nov03 0:00 \_ [ksmd]
root 25 0.0 0.0 0 0 ? S Nov03 0:00 \_ [aio/0]
root 26 0.0 0.0 0 0 ? S Nov03 0:00 \_ [crypto/0]
root 210 0.0 0.0 0 0 ? S Nov03 0:00 \_ [ata/0]
root 211 0.0 0.0 0 0 ? S Nov03 0:00 \_ [ata_aux]
root 212 0.0 0.0 0 0 ? S Nov03 0:00 \_ [scsi_eh_0]
root 213 0.0 0.0 0 0 ? S Nov03 0:00 \_ [scsi_eh_1]
root 219 0.0 0.0 0 0 ? S Nov03 0:02 \_ [mpt_poll_0]
root 220 0.0 0.0 0 0 ? S Nov03 0:00 \_ [mpt/0]
root 225 0.0 0.0 0 0 ? S Nov03 0:00 \_ [scsi_eh_2]
root 258 0.0 0.0 0 0 ? S Nov03 0:14 \_ [kjournald]
root 557 0.0 0.0 0 0 ? S Nov03 0:00 \_ [kpsmoused]
root 637 0.0 0.0 0 0 ? S Nov03 0:03 \_ [flush-8:0]
root 1164 0.0 0.0 0 0 ? S Nov03 0:03 \_ [vmmemctl]
root 1 0.0 0.0 8352 808 ? Ss Nov03 0:04 init [2]
root 331 0.0 0.0 16848 984 ? S<s Nov03 0:00 udevd --daemon
root 783 0.0 0.0 16876 880 ? S< Nov03 0:00 \_ udevd --daemon
root 784 0.0 0.0 16876 816 ? S< Nov03 0:00 \_ udevd --daemon
daemon 861 0.0 0.0 8092 536 ? Ss Nov03 0:00 /sbin/portmap
statd 873 0.0 0.0 14376 868 ? Ss Nov03 0:00 /sbin/rpc.statd
root 1034 0.0 0.0 54552 2032 ? Sl Nov03 0:00 /usr/sbin/rsyslogd -c4
root 1087 0.0 0.0 3916 628 ? Ss Nov03 0:00 /usr/sbin/acpid
root 1262 0.0 0.1 66612 3164 ? Sl Nov03 2:51 /usr/sbin/vmtoolsd
root 1289 0.0 0.5 151660 11176 ? Ss Nov03 0:06 /usr/sbin/apache2 -k start
www-data 9998 0.0 0.2 151660 5832 ? S Nov06 0:00 \_ /usr/sbin/apache2 -k start
www-data 9999 0.0 0.3 151804 6408 ? S Nov06 0:00 \_ /usr/sbin/apache2 -k start
www-data 10000 0.0 0.2 151660 5832 ? S Nov06 0:00 \_ /usr/sbin/apache2 -k start
www-data 10001 0.0 0.2 151660 5832 ? S Nov06 0:00 \_ /usr/sbin/apache2 -k start
www-data 10002 0.0 0.2 151660 5832 ? S Nov06 0:00 \_ /usr/sbin/apache2 -k start
daemon 1301 0.0 0.0 18708 436 ? Ss Nov03 0:00 /usr/sbin/atd
root 1332 0.0 0.0 22420 1056 ? Ss Nov03 0:00 /usr/sbin/cron
root 1408 0.0 0.0 49168 1144 ? Ss Nov03 0:00 /usr/sbin/sshd
root 20007 0.0 0.1 70452 3384 ? Ss 08:56 0:00 \_ sshd: root@pts/0
root 20042 0.0 0.3 24160 7044 pts/0 Ss 08:56 0:00 \_ -bash
root 14246 0.0 0.0 16444 1140 pts/0 R+ 10:41 0:00 \_ ps auxf
snmp 1416 0.0 0.2 47636 5220 ? S Nov03 0:48 /usr/sbin/snmpd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid
root 1417 0.4 0.0 43788 2004 ? Ss Nov03 36:22 /usr/sbin/snmptrapd -Ln -n -p /var/run/snmptrapd.pid
root 1427 0.0 0.1 53084 2432 ? Ss Nov03 3:12 /usr/sbin/dvtrap -D
101 1755 0.0 0.0 44140 1060 ? Ss Nov03 0:00 /usr/sbin/exim4 -bd -q30m
freerad 1803 0.0 1.1 330624 24280 ? Ssl Nov03 6:33 /usr/sbin/freeradius
root 1825 0.0 0.0 51856 1424 tty1 Ss Nov03 0:00 /bin/login --
root 1980 0.0 0.3 24096 6940 tty1 S+ Nov03 0:00 \_ -bash
root 1826 0.0 0.0 5928 620 tty2 Ss+ Nov03 0:00 /sbin/getty 38400 tty2
root 1827 0.0 0.0 5928 620 tty3 Ss+ Nov03 0:00 /sbin/getty 38400 tty3
root 1828 0.0 0.0 5928 620 tty4 Ss+ Nov03 0:00 /sbin/getty 38400 tty4
root 1829 0.0 0.0 5928 620 tty5 Ss+ Nov03 0:00 /sbin/getty 38400 tty5
root 1830 0.0 0.0 5928 620 tty6 Ss+ Nov03 0:00 /sbin/getty 38400 tty6
postgres 7890 0.0 0.3 104964 6788 ? S Nov08 0:01 /usr/lib/postgresql/8.4/bin/postgres -D /var/lib/postgresql/8.4/main -c config_file=/etc
postgres 7914 0.0 1.1 105064 22796 ? Ss Nov08 0:06 \_ postgres: writer process
postgres 7915 0.0 0.0 104964 1644 ? Ss Nov08 0:01 \_ postgres: wal writer process
postgres 7916 0.0 0.0 105240 1848 ? Ss Nov08 0:01 \_ postgres: autovacuum launcher process
postgres 7917 0.0 0.0 72320 1532 ? Ss Nov08 0:02 \_ postgres: stats collector process
postgres 7924 0.0 1.2 107468 25000 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(51997) idle
postgres 7927 0.0 1.2 107520 24876 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(51998) idle
postgres 7939 0.0 1.2 107512 24820 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(51999) idle
postgres 7941 0.0 1.2 107512 24896 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52000) idle
postgres 7951 0.0 1.2 107468 24876 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52001) idle
postgres 7959 0.0 1.2 107468 25112 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52002) idle
postgres 7962 0.0 1.2 107472 24908 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52003) idle
postgres 7963 0.0 1.2 107472 24968 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52004) idle
postgres 7966 0.0 1.2 107472 24852 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52005) idle
postgres 7969 0.0 1.2 107468 24956 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52006) idle
postgres 7986 0.0 1.2 107468 24988 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52007) idle
postgres 7989 0.0 1.2 107468 25000 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52008) idle
postgres 8017 0.0 1.2 107472 24792 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52009) idle
postgres 8022 0.0 1.2 107516 24788 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52010) idle
postgres 8025 0.0 1.2 107472 24868 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52011) idle
postgres 8028 0.0 1.2 107468 24776 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52012) idle
postgres 8034 0.0 1.2 107472 24880 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52013) idle
postgres 8035 0.0 1.2 107472 24932 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52014) idle
postgres 8054 0.0 1.2 107516 24960 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52015) idle
postgres 9559 0.0 1.2 107468 24756 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52020) idle
postgres 9566 0.0 1.2 107472 24788 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52021) idle
postgres 9569 0.0 1.2 107472 24832 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52022) idle
postgres 9572 0.0 1.2 107468 24832 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52023) idle
postgres 9573 0.0 1.2 107472 24804 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52024) idle
postgres 9574 0.0 1.2 107472 24948 ? Ss Nov08 0:01 \_ postgres: radadm radius 127.0.0.1(52025) idle
postgres 31797 0.0 0.4 106292 9576 ? Ss 10:31 0:00 \_ postgres: radadm radius 172.30.64.102(3128) idle
postgres 3146 0.0 0.4 106292 8708 ? Ss 10:33 0:00 \_ postgres: radadm radius 172.30.64.101(3595) idle
postgres 8607 0.0 0.3 106292 7032 ? Ss 10:37 0:00 \_ postgres: radadm radius 172.30.64.103(2579) idle
What can I change to make postgresql eat less ram or to free some ram?
thank you.