From c3310a7e7b23beb8819460f7e643a2352858f400 Mon Sep 17 00:00:00 2001 From: Baptiste DE RENZO <baptiste.derenzo@ubicast.eu> Date: Tue, 5 Dec 2023 14:05:08 +0000 Subject: [PATCH] Add PostgreSQL swappiness configuration in HA --- roles/postgres-ha/tasks/main.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/roles/postgres-ha/tasks/main.yml b/roles/postgres-ha/tasks/main.yml index d9860bb2..f116d107 100644 --- a/roles/postgres-ha/tasks/main.yml +++ b/roles/postgres-ha/tasks/main.yml @@ -99,6 +99,24 @@ /bin/systemctl restart postgresql@{{ repmgr_database_version }}-{{ repmgr_database_cluster }}, \ /bin/systemctl reload postgresql@{{ repmgr_database_version }}-{{ repmgr_database_cluster }} +- name: configure swappiness + ansible.builtin.copy: + dest: /etc/sysctl.d/40-swappiness.conf + owner: "root" + group: "root" + mode: "644" + content: | + # UbiCast Swappiness settings configuration for PostgreSQL on Linux + + # Parameter that controls the relative weight given to swapping out of runtime memory, + # as opposed to dropping pages from the system page cache. + # A low value causes the kernel to prefer to evict pages from the page cache while + # a higher value causes the kernel to prefer to swap out "cold" memory pages. + # Swappiness can be set to a value from 0 to 200. Default is 60. + + # See RM#38809 and https://dali.bo/j1_html#configuration-du-swap + vm.swappiness = 10 + # SSH - name: ensure postgres account have a ssh keypair -- GitLab