Ubuntu 16.04 uso inexplicável de swap

1

Não consigo entender por que meu swap está ficando cheio no meu Ubuntu 16.04, embora eu tenha bastante memória disponível:

Aoanalisarquaisprocessosestãorealmenteusandoswap:

************************************Swap'sprocessincount1systemd:1:VmSwap:520kBotrs.Daemon.pl:21002:VmSwap:3324kBsystemd-journal:2326:VmSwap:2356kBlvmetad:2353:VmSwap:8kBsystemd-udevd:2358:VmSwap:3052kB/usr/sbin/apach:25162:VmSwap:176kB/usr/sbin/apach:28879:VmSwap:176kBbash:30064:VmSwap:1460kB/usr/sbin/apach:34334:VmSwap:180kBotrs.Daemon.pl:36841:VmSwap:3708kBotrs.Daemon.pl:36847:VmSwap:2976kB/usr/sbin/apach:39489:VmSwap:176kB/usr/sbin/apach:39491:VmSwap:176kB/usr/sbin/apach:39493:VmSwap:176kB/usr/sbin/apach:39494:VmSwap:176kB/opt/otrs/bin/c:39496:VmSwap:176kB/usr/sbin/apach:39497:VmSwap:176kB/usr/sbin/apach:39498:VmSwap:176kBotrs.Daemon.pl:43266:VmSwap:4320kBsshd:43477:VmSwap:12kBsshd:43555:VmSwap:72kBbash:43556:VmSwap:1328kBbash:43577:VmSwap:212kBldapsearch:43623:VmSwap:672kBldapsearch:43625:VmSwap:648kBldapsearch:43741:VmSwap:636kBsshd:44183:VmSwap:12kBsshd:44257:VmSwap:48kBbash:44258:VmSwap:1044kBotrs.Daemon.pl:44373:VmSwap:5912kBotrs.Daemon.pl:45169:VmSwap:4344kBlxcfs:4987:VmSwap:2208kBvmtoolsd:4991:VmSwap:27168kBcron:5044:VmSwap:136kBsnapd:5053:VmSwap:4728kBsystemd-logind:5055:VmSwap:48kBaccounts-daemon:5057:VmSwap:52kBdbus-daemon:5059:VmSwap:4kBrsyslogd:5082:VmSwap:44kBotrs.Daemon.pl:50961:VmSwap:4348kBsshd:5141:VmSwap:588kBpolkitd:5149:VmSwap:4kBmysqld:5153:VmSwap:675748kBmdadm:5162:VmSwap:4kBmaster:5459:VmSwap:360kBqmgr:5462:VmSwap:68kBotrs.Daemon.pl:57161:VmSwap:4324kBsystemd:57265:VmSwap:896kB(sd-pam):57274:VmSwap:572kBotrs.Daemon.pl:57937:VmSwap:56068kB/usr/sbin/apach:8414:VmSwap:176kB************************************Swap'sprocessincount2systemd:1:VmSwap:520kBotrs.Daemon.pl:21002:VmSwap:3324kBsystemd-journal:2326:VmSwap:2356kBlvmetad:2353:VmSwap:8kBsystemd-udevd:2358:VmSwap:3052kB/usr/sbin/apach:25162:VmSwap:176kB/usr/sbin/apach:28879:VmSwap:176kBbash:30064:VmSwap:1460kB/usr/sbin/apach:34334:VmSwap:180kBotrs.Daemon.pl:36841:VmSwap:3708kBotrs.Daemon.pl:36847:VmSwap:2976kB/usr/sbin/apach:39489:VmSwap:176kB/usr/sbin/apach:39491:VmSwap:176kB/usr/sbin/apach:39493:VmSwap:176kB/usr/sbin/apach:39494:VmSwap:176kB/usr/sbin/apach:39496:VmSwap:176kB/usr/sbin/apach:39497:VmSwap:176kB/usr/sbin/apach:39498:VmSwap:176kBotrs.Daemon.pl:43266:VmSwap:4320kBsshd:43477:VmSwap:12kBsshd:43555:VmSwap:72kBbash:43556:VmSwap:1328kBbash:43577:VmSwap:212kBldapsearch:43623:VmSwap:672kBldapsearch:43625:VmSwap:648kBldapsearch:43741:VmSwap:636kBsshd:44183:VmSwap:12kBsshd:44257:VmSwap:48kBbash:44258:VmSwap:1044kBotrs.Daemon.pl:44373:VmSwap:5912kBotrs.Daemon.pl:45169:VmSwap:4344kBlxcfs:4987:VmSwap:2208kBvmtoolsd:4991:VmSwap:27168kBcron:5044:VmSwap:136kBsnapd:5053:VmSwap:4728kBsystemd-logind:5055:VmSwap:48kBaccounts-daemon:5057:VmSwap:52kBdbus-daemon:5059:VmSwap:4kBrsyslogd:5082:VmSwap:44kBotrs.Daemon.pl:50961:VmSwap:4348kBsshd:5141:VmSwap:588kBpolkitd:5149:VmSwap:4kBmysqld:5153:VmSwap:675748kBmdadm:5162:VmSwap:4kBmaster:5459:VmSwap:360kBqmgr:5462:VmSwap:68kBotrs.Daemon.pl:57161:VmSwap:4324kBsystemd:57265:VmSwap:896kB(sd-pam):57274:VmSwap:572kBotrs.Daemon.pl:57937:VmSwap:56068kB/usr/sbin/apach:8414:VmSwap:176kB************************************Swap'sprocessincount3systemd:1:VmSwap:520kBotrs.Daemon.pl:21002:VmSwap:3324kBsystemd-journal:2326:VmSwap:2356kBlvmetad:2353:VmSwap:8kBsystemd-udevd:2358:VmSwap:3052kB/usr/sbin/apach:25162:VmSwap:176kB/usr/sbin/apach:28879:VmSwap:176kBbash:30064:VmSwap:1460kB/usr/sbin/apach:34334:VmSwap:180kB/usr/sbin/apach:39489:VmSwap:176kB/usr/sbin/apach:39491:VmSwap:176kB/usr/sbin/apach:39493:VmSwap:176kB/usr/sbin/apach:39494:VmSwap:176kB/usr/sbin/apach:39496:VmSwap:176kB/usr/sbin/apach:39497:VmSwap:176kB/usr/sbin/apach:39498:VmSwap:176kBotrs.Daemon.pl:43266:VmSwap:4320kBsshd:43477:VmSwap:12kBsshd:43555:VmSwap:72kBbash:43556:VmSwap:1328kBbash:43577:VmSwap:212kBldapsearch:43623:VmSwap:672kBldapsearch:43625:VmSwap:648kBldapsearch:43741:VmSwap:636kBsshd:44183:VmSwap:12kBsshd:44257:VmSwap:48kBbash:44258:VmSwap:1044kBotrs.Daemon.pl:44373:VmSwap:5912kBotrs.Daemon.pl:45169:VmSwap:4344kBlxcfs:4987:VmSwap:2208kBvmtoolsd:4991:VmSwap:27168kBcron:5044:VmSwap:136kBsnapd:5053:VmSwap:4728kBsystemd-logind:5055:VmSwap:48kBaccounts-daemon:5057:VmSwap:52kBdbus-daemon:5059:VmSwap:4kBrsyslogd:5082:VmSwap:44kBotrs.Daemon.pl:50961:VmSwap:4348kBsshd:5141:VmSwap:588kBpolkitd:5149:VmSwap:4kBmysqld:5153:VmSwap:675748kBmdadm:5162:VmSwap:4kBmaster:5459:VmSwap:360kBqmgr:5462:VmSwap:68kBotrs.Daemon.pl:57161:VmSwap:4324kBsystemd:57265:VmSwap:896kB(sd-pam):57274:VmSwap:572kBotrs.Daemon.pl:57937:VmSwap:56068kB/usr/sbin/apach:8414:VmSwap:176kB************************************Swap'sprocessincount4systemd:1:VmSwap:520kBotrs.Daemon.pl:21002:VmSwap:3324kBsystemd-journal:2326:VmSwap:2356kBlvmetad:2353:VmSwap:8kBsystemd-udevd:2358:VmSwap:3052kB/usr/sbin/apach:25162:VmSwap:176kB/usr/sbin/apach:28879:VmSwap:176kBbash:30064:VmSwap:1460kB/usr/sbin/apach:34334:VmSwap:180kB/usr/sbin/apach:39489:VmSwap:176kB/usr/sbin/apach:39491:VmSwap:176kB/usr/sbin/apach:39493:VmSwap:176kB/usr/sbin/apach:39494:VmSwap:176kB/usr/sbin/apach:39496:VmSwap:176kB/usr/sbin/apach:39497:VmSwap:176kB/usr/sbin/apach:39498:VmSwap:176kBotrs.Daemon.pl:43266:VmSwap:4320kBsshd:43477:VmSwap:12kBsshd:43555:VmSwap:72kBbash:43556:VmSwap:1328kBbash:43577:VmSwap:212kBldapsearch:43623:VmSwap:672kBldapsearch:43625:VmSwap:648kBldapsearch:43741:VmSwap:636kBsshd:44183:VmSwap:12kBsshd:44257:VmSwap:48kBbash:44258:VmSwap:1044kBotrs.Daemon.pl:44373:VmSwap:5912kBotrs.Daemon.pl:45169:VmSwap:4344kBlxcfs:4987:VmSwap:2208kBvmtoolsd:4991:VmSwap:27168kBcron:5044:VmSwap:136kBsnapd:5053:VmSwap:4728kBsystemd-logind:5055:VmSwap:48kBaccounts-daemon:5057:VmSwap:52kBdbus-daemon:5059:VmSwap:4kBrsyslogd:5082:VmSwap:44kBotrs.Daemon.pl:50961:VmSwap:4348kBsshd:5141:VmSwap:588kBpolkitd:5149:VmSwap:4kBmysqld:5153:VmSwap:675748kBmdadm:5162:VmSwap:4kBmaster:5459:VmSwap:360kBqmgr:5462:VmSwap:68kBotrs.Daemon.pl:57161:VmSwap:4324kBsystemd:57265:VmSwap:896kB(sd-pam):57274:VmSwap:572kBotrs.Daemon.pl:57937:VmSwap:56068kB/usr/sbin/apach:8414:VmSwap:176kB

Alguémporfavorpodeexplicaromeuporqueissoestáacontecendo?Umprocessoporsisópodetrocarmesmosehouvermemóriadisponívelsuficiente?

EDITAR:

Aexecuçãodevmstatmostra0paraambossianso(observequeasaídaestátruncadaeexecuteiocomandoporumbomtempo):

    
por yesOrMaybeWhatever 23.03.2018 / 09:24

1 resposta

2

Sim, os processos podem ser trocados mesmo quando há memória disponível. Isso é controlado pelo valor swappiness da memória virtual que, como você mostra, é definido como 60 em seu sistema (o padrão em muitas instalações). A documentação da Red Hat tem uma boa explicação (esta é aplicável a qualquer Linux):

swappiness

A value from 0 to 100 which controls the degree to which the system favors anonymous memory or the page cache. A high value improves file-system performance, while aggressively swapping less active processes out of physical memory. A low value avoids swapping processes out of memory, which usually decreases latency, at the cost of I/O performance. The default value is 60.

A low swappiness value is recommended for database workloads. For example, for Oracle databases, Red Hat recommends a swappiness value of 10.

Se você quiser configurá-lo para um valor mais baixo, 10 por exemplo, edite /etc/sysctl.conf e adicione uma linha como esta:

vm.swappiness=10

Observe que, para versões mais recentes de systemd , você precisa editar / criar arquivos em /etc/sysctl.d/ . Como explicado no Arch Wiki :

Note: From version 207 and 21x, systemd only applies settings from /etc/sysctl.d/*.conf and /usr/lib/sysctl.d/*.conf. If you had customized /etc/sysctl.conf, you need to rename it as /etc/sysctl.d/99-sysctl.conf. If you had e.g. /etc/sysctl.d/foo, you need to rename it to /etc/sysctl.d/foo.conf.

No entanto, tenha em mente que a troca não é necessariamente um problema. Tudo depende do que sua máquina está fazendo. Existe uma resposta agradável e detalhada abordando esta questão no Ask Ubuntu, que eu sugiro que você leia. Basicamente, a menos que sua máquina pareça lenta, que seja.

Leitura adicional:

por 23.03.2018 / 10:26

Tags