====== Gestion du swap ====== Nominalement, les vm et les pm de l'infra n'ont pas à swapper. Si une machine swappe quand même, c'est soit un problème de dimensionnement, soit un incident ponctuel (processus qui part en vrille). Dans ces cas, la présence de swap est une sécurité pour la continuité de fonctionnement (sinon kill aveugle). Afin de minimiser l'utilisation du cache, réglage du vm.swappiness=1 via sexy-chapril dans : * /etc/sysctl.d/ * /etc/systemd/system/systemd-sysctl.service.d/swappiness.conf Voir https://agir.april.org/issues/4716. Notes : De : Emmanuel Lacour via RT Sujet : [Easter-eggs #73359] Re: Question de swappiness pour le SI April Salut à tous, petite mise à jour sur cette demande avant de la clore: on a constaté qu'à priori en Debian buster, vm.swappiness=1 ne suffisait pas car les services sont démarés en cgroups v1 qui met un swappiness par défaut de 60, quelle que soit la valeur de vm.swappiness. Vu surtout sur des serveurs avec MySQL ou InfluxDB qui semblaient swapper sans réelle raison. On a trouvé ça: https://github.com/systemd/systemd/issues/9276 cf. par exemple: cat /sys/fs/cgroup/memory/system.slice/memory.swappiness Du coup la solution semble être d'ajouter une action post à systemd-sysctl: cat /etc/systemd/system/systemd-sysctl.service.d/swappiness.conf [Service] ExecStartPost=/bin/find /sys/fs/cgroup -mindepth 2 -maxdepth 2 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; ExecStartPost=/bin/find /sys/fs/cgroup -mindepth 3 -maxdepth 3 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; ExecStartPost=/bin/find /sys/fs/cgroup -mindepth 4 -maxdepth 4 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; ExecStartPost=/bin/find /sys/fs/cgroup -mindepth 5 -maxdepth 5 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; ExecStartPost=/bin/find /sys/fs/cgroup -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; puis: systemctl daemon-reload systemctl restart systemd-sysctl.service testé sur plusieurs VMs chez nous avec succès Appliqué au SI Chapril, ça donne : =(^-^)=root@lamp:~# cat /etc/systemd/system/systemd-sysctl.service.d/chapril-swappiness-post.conf [Service] ExecStartPost=/usr/bin/find /sys/fs/cgroup -mindepth 2 -maxdepth 2 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; ExecStartPost=/usr/bin/find /sys/fs/cgroup -mindepth 3 -maxdepth 3 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; ExecStartPost=/usr/bin/find /sys/fs/cgroup -mindepth 4 -maxdepth 4 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; ExecStartPost=/usr/bin/find /sys/fs/cgroup -mindepth 5 -maxdepth 5 -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; ExecStartPost=/usr/bin/find /sys/fs/cgroup -name memory.swappiness -exec /bin/sh -c 'sysctl -n vm.swappiness > "{}"' \; À noter que c'est géré automatiquement via un paquet April \o/