{"id":6863,"date":"2026-05-19T21:58:37","date_gmt":"2026-05-19T19:58:37","guid":{"rendered":"https:\/\/rootfan.com\/?p=6863"},"modified":"2026-05-27T15:05:08","modified_gmt":"2026-05-27T13:05:08","slug":"configuration-de-repmgr-pour-postgresql","status":"publish","type":"post","link":"https:\/\/rootfan.com\/fr\/postgresql-repmgr-setup\/","title":{"rendered":"Mise en place de la r\u00e9plication et du basculement automatique avec repmgr dans PostgreSQL"},"content":{"rendered":"<p class=\"wp-block-paragraph\">PostgreSQL n'inclut pas de basculement automatique pr\u00eat \u00e0 l'emploi.<br>Lorsque le serveur principal tombe en panne, quelqu'un doit promouvoir manuellement le serveur de secours, ce qui entra\u00eene une interruption de service.<br>repmgr ajoute un d\u00e9mon de basculement automatique (repmgrd) qui surveille le cluster et promeut le standby en quelques secondes lorsque le primaire \u00e9choue.<br>Ce guide explique comment configurer un cluster PostgreSQL 18 \u00e0 deux n\u0153uds avec r\u00e9plication en streaming et basculement automatique sur Ubuntu 24.04, en utilisant repmgr 5.x.<br>Chaque \u00e9tape a \u00e9t\u00e9 ex\u00e9cut\u00e9e en direct sur un cluster r\u00e9el et la sortie a \u00e9t\u00e9 v\u00e9rifi\u00e9e.<\/p>\n\n\n\n<!--more-->\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Une veille de diffusion en continu qui n\u00e9cessite une promotion manuelle n'est pas une configuration de haute disponibilit\u00e9 \u2013 c'est une configuration de reprise apr\u00e8s sinistre.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">La diff\u00e9rence compte lors d'un incident \u00e0 3 heures du matin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PostgreSQL est livr\u00e9 avec les \u00e9l\u00e9ments constitutifs de la r\u00e9plication, mais la logique de basculement automatique r\u00e9side dans un outil s\u00e9par\u00e9.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">repmgr est l'outil auquel la plupart des DBA PostgreSQL se r\u00e9f\u00e8rent en premier : il est l\u00e9ger, bien document\u00e9 et s'int\u00e8gre proprement avec systemd.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ce guide construit la pile compl\u00e8te : r\u00e9plication de flux \u00e0 partir de z\u00e9ro, repmgrd fonctionnant en tant que d\u00e9mon, et un basculement automatique test\u00e9 qui r\u00e9cup\u00e8re le cluster sans intervention humaine.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table des mati\u00e8res<\/h2><nav><ul><li><a href=\"#the-environment\">L'environnement<\/a><\/li><li><a href=\"#step-1-install-postgre-sql-18-and-repmgr\">\u00c9tape 1 \u2014 Installer PostgreSQL 18 et repmgr<\/a><\/li><li><a href=\"#step-2-configure-postgre-sql-for-streaming-replication\">\u00c9tape 2 \u2014 Configurer PostgreSQL pour la r\u00e9plication en flux<\/a><\/li><li><a href=\"#step-3-allow-replication-connections-in-pg-hba-conf\">\u00c9tape 3 \u2014 Autoriser les connexions de r\u00e9plication dans pg_hba.conf<\/a><\/li><li><a href=\"#step-4-create-the-repmgr-user-and-database\">\u00c9tape 4 \u2014 Cr\u00e9er l'utilisateur et la base de donn\u00e9es repmgr<\/a><\/li><li><a href=\"#step-5-configure-repmgr-on-both-nodes\">\u00c9tape\u00a05\u00a0\u2014 Configurer repmgr sur les deux n\u0153uds<\/a><\/li><li><a href=\"#step-6-set-up-ssh-keys-and-passwordless-sudo\">\u00c9tape 6 \u2014 Configuration des cl\u00e9s SSH et du sudo sans mot de passe<\/a><\/li><li><a href=\"#step-7-register-the-primary-and-clone-the-standby\">\u00c9tape 7 \u2014 Enregistrer le primaire et cloner le secondaire<\/a><\/li><li><a href=\"#step-8-start-repmgrd-for-automatic-failover\">\u00c9tape 8 \u2014 D\u00e9marrer repmgrd pour le basculement automatique<\/a><\/li><li><a href=\"#step-9-test-automatic-failover\">\u00c9tape 9 \u2014 Tester le basculement automatique<\/a><\/li><li><a href=\"#step-10-rejoin-the-failed-node-as-a-standby\">\u00c9tape 10 \u2014 Rejoindre le n\u0153ud d\u00e9faillant en tant que secondaire<\/a><\/li><li><a href=\"#frequently-asked-questions\">Foire aux questions<\/a><ul><li><a href=\"#faq-question-1779206653802\">repmgr est-il compatible avec PostgreSQL 18 ?<\/a><\/li><li><a href=\"#faq-question-1779206654802\">Pourquoi mon basculement planifi\u00e9 \u00e9choue-t-il avec le message \u201c impossible de confirmer l'arr\u00eat du primaire \u201d ?<\/a><\/li><li><a href=\"#faq-question-1779206655802\">Pourquoi repmgrd ne d\u00e9clenche-t-il pas le basculement m\u00eame si le primaire est hors ligne ?<\/a><\/li><li><a href=\"#faq-question-1779206656802\">Le n\u0153ud r\u00e9trograd\u00e9 red\u00e9marre-t-il automatiquement apr\u00e8s un basculement ?<\/a><\/li><li><a href=\"#faq-question-1779206657802\">Qu'est-ce que pg_rewind et pourquoi est-il n\u00e9cessaire pour la rejointe d'un n\u0153ud ?<\/a><\/li><\/ul><\/li><li><a href=\"#in-summary\">En r\u00e9sum\u00e9<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-environment\">L'environnement<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Ce guide utilise deux serveurs Ubuntu 24.04 sur le m\u00eame sous-r\u00e9seau.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>H\u00f4te<\/th><th>CI<\/th><th>R\u00f4le initial<\/th><\/tr><\/thead><tbody><tr><td>serveur1<\/td><td>192.168.0.181<\/td><td>Primaire<\/td><\/tr><tr><td>serveur2<\/td><td>192.168.0.182<\/td><td>Attendez<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">PostgreSQL 18 et repmgr 5.5.0 sont install\u00e9s \u00e0 partir du d\u00e9p\u00f4t PGDG sur les deux serveurs.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-1-install-postgre-sql-18-and-repmgr\">\u00c9tape 1 \u2014 Installer PostgreSQL 18 et repmgr<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PostgreSQL 18 n'est pas dans le d\u00e9p\u00f4t par d\u00e9faut d'Ubuntu 24.04.<br>Le <code>postgresql-common<\/code> le paquet comprend un script officiel qui ajoute automatiquement le d\u00e9p\u00f4t APT PGDG et la cl\u00e9 de signature.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sur les deux serveurs :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo apt install -y postgresql-common\nsudo \/usr\/share\/postgresql-common\/pgdg\/apt.postgresql.org.sh\n\nsudo apt update\nsudo apt install -y postgresql-18 postgresql-18-repmgr\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">V\u00e9rifier l'installation :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\npsql --version\n# Expected: psql (PostgreSQL) 18.x\n\nrepmgr --version\n# Expected: repmgr 5.x\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Sur server2, arr\u00eatez PostgreSQL et supprimez le r\u00e9pertoire de donn\u00e9es par d\u00e9faut.<br>repmgr clonera le r\u00e9pertoire de donn\u00e9es du primaire vers server2 dans une \u00e9tape ult\u00e9rieure \u2013 si un r\u00e9pertoire de donn\u00e9es existe d\u00e9j\u00e0, <code>repmgr standby clone<\/code> refusera de continuer.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2\nsudo systemctl stop postgresql\nsudo rm -rf \/var\/lib\/postgresql\/18\/main\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-2-configure-postgre-sql-for-streaming-replication\">\u00c9tape 2 \u2014 Configurer PostgreSQL pour la r\u00e9plication en flux<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Ces param\u00e8tres doivent \u00eatre d\u00e9finis dans <code>\/etc\/postgresql\/18\/main\/postgresql.conf<\/code> sur les deux serveurs avant de configurer la r\u00e9plication.<br>repmgr n\u00e9cessite <code>wal_log_hints<\/code> et <code>biblioth\u00e8ques_precharg\u00e9es_partag\u00e9es<\/code> \u2014 sans eux, le processus de rejoin de n\u0153ud (pg_rewind) et le d\u00e9mon repmgrd ne fonctionneront pas.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sur les deux serveurs, modifiez <code>\/etc\/postgresql\/18\/main\/postgresql.conf<\/code>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\">\nlisten_addresses = &#8216;*'\nwal_level = replica\nmax_wal_senders = 10\nmax_replication_slots = 10\nhot_standby = on\nwal_log_hints = on\nshared_preload_libraries = &#8216;repmgr'\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Ces param\u00e8tres n\u00e9cessitent un red\u00e9marrage de PostgreSQL pour prendre effet.<br>Ne red\u00e9marrez pas encore \u2014 ajoutez le <code>pg_hba.conf<\/code> entr\u00e9es d'abord afin de ne pas red\u00e9marrer deux fois.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-3-allow-replication-connections-in-pg-hba-conf\">\u00c9tape 3 \u2014 Autoriser les connexions de r\u00e9plication dans pg_hba.conf<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sur les deux serveurs, ajoutez ces lignes \u00e0 <code>\/etc\/postgresql\/18\/main\/pg_hba.conf<\/code>.<br>Ceux-ci permettent la <code>repmgr<\/code> utilisateur pour se connecter aux requ\u00eates de gestion et au streaming WAL depuis l'un ou l'autre n\u0153ud.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo tee -a \/etc\/postgresql\/18\/main\/pg_hba.conf &gt; \/dev\/null &lt;&lt; &#039;EOF&#039;\n\nhost    repmgr          repmgr          192.168.0.181\/32        scram-sha-256\nhost    repmgr          repmgr          192.168.0.182\/32        scram-sha-256\nhost    replication     repmgr          192.168.0.181\/32        scram-sha-256\nhost    replication     repmgr          192.168.0.182\/32        scram-sha-256\nEOF\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Red\u00e9marrez maintenant PostgreSQL sur server1 (server2 n'a pas encore de r\u00e9pertoire de donn\u00e9es) :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server1\nsudo systemctl restart postgresql\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-4-create-the-repmgr-user-and-database\">\u00c9tape 4 \u2014 Cr\u00e9er l'utilisateur et la base de donn\u00e9es repmgr<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Ex\u00e9cutez ces commandes sur server1 (le primaire) uniquement.<br>La sauvegarde recevra le sch\u00e9ma repmgr par r\u00e9plication dans une \u00e9tape ult\u00e9rieure.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres psql -c &quot;CREATE USER repmgr WITH SUPERUSER REPLICATION LOGIN PASSWORD &#039;repmgr&#039;;&quot;\nsudo -u postgres psql -c &quot;CREATE DATABASE repmgr OWNER repmgr;&quot;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Ajouter un <code>.pgpass<\/code> fichier pour l'utilisateur postgres de l'OS sur les deux serveurs afin que repmgr puisse se connecter sans invite de mot de passe.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sur le serveur1 :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres bash -c &#039;cat &gt; \/var\/lib\/postgresql\/.pgpass &lt;&lt;EOF\n192.168.0.181:5432:repmgr:repmgr:repmgr\n192.168.0.182:5432:repmgr:repmgr:repmgr\n192.168.0.181:5432:replication:repmgr:repmgr\n192.168.0.182:5432:replication:repmgr:repmgr\nEOF&#039;\nsudo chmod 600 \/var\/lib\/postgresql\/.pgpass\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Sur le serveur2 :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres bash -c &#039;cat &gt; \/var\/lib\/postgresql\/.pgpass &lt;&lt;EOF\n192.168.0.181:5432:repmgr:repmgr:repmgr\n192.168.0.182:5432:repmgr:repmgr:repmgr\n192.168.0.181:5432:replication:repmgr:repmgr\n192.168.0.182:5432:replication:repmgr:repmgr\nEOF&#039;\nsudo chmod 600 \/var\/lib\/postgresql\/.pgpass\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-5-configure-repmgr-on-both-nodes\">\u00c9tape\u00a05\u00a0\u2014 Configurer repmgr sur les deux n\u0153uds<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Cr\u00e9er <code>\/etc\/repmgr.conf<\/code> sur chaque serveur.<br>Le <code>pg_bindir<\/code> param\u00e8tre est requis sur Ubuntu \u2014 le <code>pg_rewind<\/code> le binaire n'est pas dans le PATH par d\u00e9faut pour l'utilisateur OS postgres, et repmgr en a besoin lors de la r\u00e9int\u00e9gration du n\u0153ud apr\u00e8s un basculement.<br>Le <code>commande_d\u00e9marrage_service<\/code> et <code>commande_arr\u00eat_service<\/code> param\u00e8tres sont requis : sans <code>commande_arr\u00eat_service<\/code>, les basculements planifi\u00e9s \u00e9chouent avec \u201c impossible de confirmer l'arr\u00eat du primaire \u201d ; sans <code>commande_d\u00e9marrage_service<\/code>, un n\u0153ud ne peut pas rejoindre le cluster automatiquement apr\u00e8s avoir \u00e9t\u00e9 r\u00e9initialis\u00e9.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sur le serveur1 :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo tee \/etc\/repmgr.conf &gt; \/dev\/null &lt;&lt; &#039;EOF&#039;\nnode_id=1\nnode_name=&#039;server1&#039;\nconninfo=&#039;host=192.168.0.181 user=repmgr dbname=repmgr connect_timeout=2&#039;\ndata_directory=&#039;\/var\/lib\/postgresql\/18\/main&#039;\n\nfailover=automatic\npromote_command=&#039;repmgr standby promote -f \/etc\/repmgr.conf --log-to-file&#039;\nfollow_command=&#039;repmgr standby follow -f \/etc\/repmgr.conf --upstream-node-id=%n --log-to-file&#039;\n\nuse_replication_slots=yes\nmonitoring_history=yes\nlog_file=&#039;\/var\/log\/repmgr\/repmgr.log&#039;\n\npg_bindir=&#039;\/usr\/lib\/postgresql\/18\/bin&#039;\nservice_start_command=&#039;sudo systemctl start postgresql&#039;\nservice_stop_command=&#039;sudo systemctl stop postgresql&#039;\n\nnode_rejoin_timeout=120\nstandby_reconnect_timeout=120\nEOF\n\nsudo chown postgres:postgres \/etc\/repmgr.conf\nsudo chmod 640 \/etc\/repmgr.conf\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Sur le serveur2, uniquement <code>id_noeud<\/code> et <code>nom_du_n\u0153ud<\/code> diff\u00e9rent :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo tee \/etc\/repmgr.conf &gt; \/dev\/null &lt;&lt; &#039;EOF&#039;\nnode_id=2\nnode_name=&#039;server2&#039;\nconninfo=&#039;host=192.168.0.182 user=repmgr dbname=repmgr connect_timeout=2&#039;\ndata_directory=&#039;\/var\/lib\/postgresql\/18\/main&#039;\n\nfailover=automatic\npromote_command=&#039;repmgr standby promote -f \/etc\/repmgr.conf --log-to-file&#039;\nfollow_command=&#039;repmgr standby follow -f \/etc\/repmgr.conf --upstream-node-id=%n --log-to-file&#039;\n\nuse_replication_slots=yes\nmonitoring_history=yes\nlog_file=&#039;\/var\/log\/repmgr\/repmgr.log&#039;\n\npg_bindir=&#039;\/usr\/lib\/postgresql\/18\/bin&#039;\nservice_start_command=&#039;sudo systemctl start postgresql&#039;\nservice_stop_command=&#039;sudo systemctl stop postgresql&#039;\n\nnode_rejoin_timeout=120\nstandby_reconnect_timeout=120\nEOF\n\nsudo chown postgres:postgres \/etc\/repmgr.conf\nsudo chmod 640 \/etc\/repmgr.conf\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Cr\u00e9ez le r\u00e9pertoire de journaux sur les deux serveurs :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo mkdir -p \/var\/log\/repmgr\nsudo chown postgres:postgres \/var\/log\/repmgr\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-6-set-up-ssh-keys-and-passwordless-sudo\">\u00c9tape 6 \u2014 Configuration des cl\u00e9s SSH et du sudo sans mot de passe<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Les basculements planifi\u00e9s n\u00e9cessitent que repmgr se connecte par SSH d'un n\u0153ud \u00e0 l'autre en tant qu'utilisateur postgres du syst\u00e8me d'exploitation et ex\u00e9cute <code>systemctl stop postgresql<\/code>.<br>Cette \u00e9tape est obligatoire \u2014 sans elle, les basculements \u00e9chouent au moment o\u00f9 repmgr tente d'arr\u00eater le primaire actuel \u00e0 distance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Configuration de la cl\u00e9 SSH :<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sur le serveur1 \u2014 g\u00e9n\u00e9rer une cl\u00e9 et afficher la cl\u00e9 publique :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server1\nsudo -u postgres ssh-keygen -t ed25519 -N &#039;&#039; -f \/var\/lib\/postgresql\/.ssh\/id_ed25519\nsudo -u postgres cat \/var\/lib\/postgresql\/.ssh\/id_ed25519.pub\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Sur server2 \u2014 autoriser la cl\u00e9 publique de server1 :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2\nsudo -u postgres mkdir -p \/var\/lib\/postgresql\/.ssh\n# Paste the public key from server1 in place of &lt;server1-public-key&gt;\nsudo -u postgres bash -c &#039;echo &quot;&lt;server1-public-key&gt;&quot; &gt;&gt; \/var\/lib\/postgresql\/.ssh\/authorized_keys&#039;\nsudo chmod 700 \/var\/lib\/postgresql\/.ssh\nsudo chmod 600 \/var\/lib\/postgresql\/.ssh\/authorized_keys\nsudo chown -R postgres:postgres \/var\/lib\/postgresql\/.ssh\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">R\u00e9p\u00e9tez dans l'autre sens \u2014 sur server2, g\u00e9n\u00e9rez une cl\u00e9, puis autorisez-la sur server1\u00a0:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2\nsudo -u postgres ssh-keygen -t ed25519 -N &#039;&#039; -f \/var\/lib\/postgresql\/.ssh\/id_ed25519\nsudo -u postgres cat \/var\/lib\/postgresql\/.ssh\/id_ed25519.pub\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server1\nsudo -u postgres mkdir -p \/var\/lib\/postgresql\/.ssh\nsudo -u postgres bash -c &#039;echo &quot;&lt;server2-public-key&gt;&quot; &gt;&gt; \/var\/lib\/postgresql\/.ssh\/authorized_keys&#039;\nsudo chmod 700 \/var\/lib\/postgresql\/.ssh\nsudo chmod 600 \/var\/lib\/postgresql\/.ssh\/authorized_keys\nsudo chown -R postgres:postgres \/var\/lib\/postgresql\/.ssh\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">V\u00e9rifier \u00e0 partir de chaque n\u0153ud (type <code>oui<\/code> si on vous demande d'accepter la cl\u00e9 h\u00f4te (uniquement la premi\u00e8re fois) :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server1\nsudo -u postgres ssh postgres@192.168.0.182 &quot;echo OK&quot;\n# Expected: OK\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2\nsudo -u postgres ssh postgres@192.168.0.181 &quot;echo OK&quot;\n# Expected: OK\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Sudo sans mot de passe \u2014 sur les deux serveurs :<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Cr\u00e9er <code>\/etc\/sudoers.d\/postgres-repmgr<\/code> pour permettre \u00e0 l'utilisateur postgres de d\u00e9marrer et d'arr\u00eater PostgreSQL sans mot de passe.<br>Le chemin doit \u00eatre <code>\/usr\/bin\/systemctl<\/code> \u2014 sur Ubuntu 24.04, c'est l\u00e0 que se trouve systemctl, et sudo valide le chemin exact.<br>Le fichier doit avoir les permissions 440 \u2014 sudo ignore silencieusement les fichiers ayant des permissions lisibles par tout le monde.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo tee \/etc\/sudoers.d\/postgres-repmgr &gt; \/dev\/null &lt;&lt; &#039;EOF&#039;\npostgres ALL=(ALL) NOPASSWD: \/usr\/bin\/systemctl start postgresql, \/usr\/bin\/systemctl stop postgresql, \/usr\/bin\/systemctl restart postgresql\nEOF\nsudo chmod 440 \/etc\/sudoers.d\/postgres-repmgr\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">V\u00e9rifier \u2014 aucune invite de mot de passe attendue :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres sudo systemctl status postgresql@18-main\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-7-register-the-primary-and-clone-the-standby\">\u00c9tape 7 \u2014 Enregistrer le primaire et cloner le secondaire<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sur server1, enregistrez l'instance PostgreSQL en cours d'ex\u00e9cution comme n\u0153ud principal :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server1\nsudo -u postgres repmgr -f \/etc\/repmgr.conf primary register\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Sur le serveur2, ex\u00e9cutez d'abord une simulation pour confirmer la connectivit\u00e9 :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2\nsudo -u postgres repmgr -h 192.168.0.181 -U repmgr -d repmgr \\\n  -f \/etc\/repmgr.conf standby clone --dry-run\n# Expected: &quot;STANDBY CLONE (target node \\&quot;server2\\&quot;) would complete successfully&quot;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Ensuite, lancez le clonage r\u00e9el :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2\nsudo -u postgres repmgr -h 192.168.0.181 -U repmgr -d repmgr \\\n  -f \/etc\/repmgr.conf standby clone\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Sur Ubuntu, <code>postgresql.conf<\/code> et <code>pg_hba.conf<\/code> vivre dans <code>\/etc\/postgresql\/18\/main\/<\/code> \u2014 en dehors du r\u00e9pertoire de donn\u00e9es.<br><code>pg_basebackup<\/code> ne copie que le r\u00e9pertoire des donn\u00e9es, donc ces fichiers de configuration ne sont pas copi\u00e9s automatiquement.<br>Copiez-les du serveur1 au serveur2 :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server1 \u2014 stage the files for transfer\nsudo cp \/etc\/postgresql\/18\/main\/postgresql.conf \/tmp\/postgresql.conf\nsudo cp \/etc\/postgresql\/18\/main\/pg_hba.conf \/tmp\/pg_hba.conf\nsudo chmod 644 \/tmp\/postgresql.conf \/tmp\/pg_hba.conf\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2 \u2014 copy and install\nscp fernando@192.168.0.181:\/tmp\/postgresql.conf \/tmp\/postgresql.conf\nscp fernando@192.168.0.181:\/tmp\/pg_hba.conf \/tmp\/pg_hba.conf\nsudo cp \/tmp\/postgresql.conf \/etc\/postgresql\/18\/main\/postgresql.conf\nsudo cp \/tmp\/pg_hba.conf \/etc\/postgresql\/18\/main\/pg_hba.conf\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">D\u00e9marrer PostgreSQL sur le serveur2 et l'enregistrer en tant que r\u00e9plique :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2\nsudo systemctl start postgresql\nsudo -u postgres repmgr -f \/etc\/repmgr.conf standby register\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">V\u00e9rifier le cluster depuis l'un ou l'autre n\u0153ud :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres repmgr -f \/etc\/repmgr.conf cluster show\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">R\u00e9sultat attendu :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string\n----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------\n 1  | server1 | primary | * running |          | default  | 100      | 1        | host=192.168.0.181 user=repmgr dbname=repmgr connect_timeout=2\n 2  | server2 | standby |   running | server1  | default  | 100      | 1        | host=192.168.0.182 user=repmgr dbname=repmgr connect_timeout=2\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-8-start-repmgrd-for-automatic-failover\">\u00c9tape 8 \u2014 D\u00e9marrer repmgrd pour le basculement automatique<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">repmgrd est le d\u00e9mon de surveillance qui d\u00e9clenche le basculement automatique.<br>Sur Ubuntu 24.04, repmgr n'inclut pas de fichier d'unit\u00e9 systemd pour repmgrd \u2014 d\u00e9marrez-le manuellement en utilisant <code>--daemoniser<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sur les deux serveurs :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres repmgrd -f \/etc\/repmgr.conf --daemonize\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">V\u00e9rifiez que le d\u00e9mon est en cours d'ex\u00e9cution et non en pause :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres repmgr daemon status\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">R\u00e9sultat attendu :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n ID | Name    | Role    | Status    | repmgrd Active | PID  | Paused? | Upstream\n----+---------+---------+-----------+----------------+------+---------+---------\n 1  | server1 | primary | * running | yes            | XXXX | no      | n\/a\n 2  | server2 | standby |   running | yes            | XXXX | no      | server1\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Le <code>Mis en pause ? non<\/code> la colonne est critique \u2014 repmgrd s'interrompt lui-m\u00eame apr\u00e8s une tentative de basculement \u00e9chou\u00e9e et ne tentera pas un nouveau basculement tant qu'il sera en pause.<br>Avant tout test de basculement, v\u00e9rifiez que les deux n\u0153uds affichent <code>Mis en pause ? non<\/code>.<br>Si un n\u0153ud pr\u00e9sente <code>En pause ? oui<\/code>, ex\u00e9cuter :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres repmgr daemon unpause\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-9-test-automatic-failover\">\u00c9tape 9 \u2014 Tester le basculement automatique<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Arr\u00eater PostgreSQL sur server1 pour simuler une d\u00e9faillance du primaire :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server1\nsudo systemctl stop postgresql\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Sur server2, observez la r\u00e9action de repmgrd :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2\nsudo tail -f -n 50 \/var\/log\/repmgr\/repmgr.log\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">repmgrd attend un nombre configurable de tentatives de reconnexion (par d\u00e9faut : 6 tentatives \u00d7 10 secondes = ~60 secondes) avant de promouvoir la r\u00e9plique.<br>Lorsque la promotion est termin\u00e9e, le journal indique :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nNOTICE: promoting standby to primary\nNOTICE: STANDBY PROMOTE successful\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">V\u00e9rifier la nouvelle topologie :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server2\nsudo -u postgres repmgr -f \/etc\/repmgr.conf cluster show\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">server2 est maintenant principal, server1 est indiqu\u00e9 comme indisponible.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-10-rejoin-the-failed-node-as-a-standby\">\u00c9tape 10 \u2014 Rejoindre le n\u0153ud d\u00e9faillant en tant que secondaire<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apr\u00e8s le basculement, server1 doit \u00eatre r\u00e9int\u00e9gr\u00e9.<br>PostgreSQL a peut-\u00eatre progress\u00e9 sur server2 pendant que server1 \u00e9tait en panne \u2014 les r\u00e9pertoires de donn\u00e9es ont maintenant diverg\u00e9.<br>repmgr utilise <code>pg_rewind<\/code> pour synchroniser server1 sur la chronologie du nouveau primaire avant de d\u00e9marrer la r\u00e9plication.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sur server1, v\u00e9rifiez que PostgreSQL est arr\u00eat\u00e9, puis ex\u00e9cutez :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# On server1\nsudo systemctl status postgresql@18-main\n# Expected: inactive (dead) \u2014 if active, stop it first: sudo systemctl stop postgresql\n\nsudo -u postgres repmgr node rejoin \\\n  -d &#039;host=192.168.0.182 user=repmgr dbname=repmgr&#039; \\\n  -f \/etc\/repmgr.conf \\\n  --force-rewind \\\n  --verbose\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><code>--rembobinage-forc\u00e9<\/code> demande \u00e0 repmgr de s'ex\u00e9cuter <code>pg_rewind<\/code> quelle que soit la divergence de chronologie v\u00e9rifi\u00e9e.<br>Sur Ubuntu 24.04, la reconnexion expire parfois avant que PostgreSQL ne termine le d\u00e9marrage en tant que r\u00e9plique.<br>Si la commande se termine avec un message de d\u00e9lai d'attente mais que le journal indique que pg_rewind s'est termin\u00e9 avec succ\u00e8s, d\u00e9marrez PostgreSQL manuellement :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo systemctl start postgresql\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Enregistrer le serveur server1 dans les m\u00e9tadonn\u00e9es de repmgr et d\u00e9marrer le d\u00e9mon repmgrd.<br>Le <code>--forcer<\/code> le drapeau est requis car server1 \u00e9tait pr\u00e9c\u00e9demment enregistr\u00e9 comme principal :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres repmgr -f \/etc\/repmgr.conf standby register --force\nsudo -u postgres repmgrd -f \/etc\/repmgr.conf --daemonize\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">V\u00e9rifier que les deux n\u0153uds fonctionnent :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo -u postgres repmgr -f \/etc\/repmgr.conf cluster show\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Attendu : server1 list\u00e9 comme secondaire, server2 comme principal.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"frequently-asked-questions\">Foire aux questions<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list\">\n<div id=\"faq-question-1779206653802\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question\"><strong>repmgr est-il compatible avec PostgreSQL 18 ?<\/strong><\/h3>\n<div class=\"rank-math-answer\">\n\n<p>Oui.<br \/>repmgr 5.5.0 prend en charge PostgreSQL 18.<br \/>Installer depuis le d\u00e9p\u00f4t PGDG en utilisant le paquet postgresql-18-repmgr.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779206654802\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question\"><strong>Pourquoi mon basculement planifi\u00e9 \u00e9choue-t-il avec le message \u201c impossible de confirmer l'arr\u00eat du primaire \u201d ?<\/strong><\/h3>\n<div class=\"rank-math-answer\">\n\n<p>Le param\u00e8tre service_stop_command n'est pas d\u00e9fini dans \/etc\/repmgr.conf.<br \/>repmgr doit arr\u00eater le primaire actuel via SSH lors d'un basculement et n\u00e9cessite une commande explicite pour ce faire.<br \/>Ajoutez service_stop_command='sudo systemctl stop postgresql' \u00e0 \/etc\/repmgr.conf sur les deux n\u0153uds.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779206655802\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question\"><strong>Pourquoi repmgrd ne d\u00e9clenche-t-il pas le basculement m\u00eame si le primaire est hors ligne ?<\/strong><\/h3>\n<div class=\"rank-math-answer\">\n\n<p>repmgrd est en pause.<br \/>Le d\u00e9mon s'arr\u00eate lui-m\u00eame apr\u00e8s une tentative de basculement \u00e9chou\u00e9e pour \u00e9viter la promotion en cascade dans les sc\u00e9narios de split-brain.<br \/>Ex\u00e9cutez `repmgr daemon status` pour v\u00e9rifier la colonne `Paused?` et `repmgr daemon unpause` pour reprendre la surveillance.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779206656802\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question\"><strong>Le n\u0153ud r\u00e9trograd\u00e9 red\u00e9marre-t-il automatiquement apr\u00e8s un basculement ?<\/strong><\/h3>\n<div class=\"rank-math-answer\">\n\n<p>Non.<br \/>repmgr arr\u00eate l'ancien primaire lors du basculement mais ne le red\u00e9marre pas.<br \/>La documentation officielle de repmgr stipule : Le primaire d'origine sera arr\u00eat\u00e9 dans tous les cas, et devra \u00eatre r\u00e9int\u00e9gr\u00e9 manuellement dans le cluster de r\u00e9plication.<br \/>Une fois la bascule termin\u00e9e, ex\u00e9cutez sudo systemctl start postgresql sur le n\u0153ud r\u00e9trograd\u00e9 pour le r\u00e9tablir en tant que r\u00e9plique.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779206657802\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question\"><strong>Qu'est-ce que pg_rewind et pourquoi est-il n\u00e9cessaire pour la rejointe d'un n\u0153ud ?<\/strong><\/h3>\n<div class=\"rank-math-answer\">\n\n<p>pg_rewind resynchronise un r\u00e9pertoire de donn\u00e9es PostgreSQL qui a diverg\u00e9 de la ligne temporelle principale.<br \/>Cela se produit apr\u00e8s un basculement \u2014 l'ancien n\u0153ud primaire peut avoir valid\u00e9 des transactions qui n'ont pas \u00e9t\u00e9 r\u00e9pliqu\u00e9es avant sa d\u00e9faillance.<br \/>pg_rewind remplace ces blocs diverg\u00e9s par les donn\u00e9es correctes du nouveau primaire, permettant au n\u0153ud de reprendre la r\u00e9plication sans une sauvegarde de base compl\u00e8te.<br \/>wal_log_hints = on doit \u00eatre d\u00e9fini dans postgresql.conf pour que pg_rewind fonctionne.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"in-summary\">En r\u00e9sum\u00e9<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">La r\u00e9plication en flux de PostgreSQL est int\u00e9gr\u00e9e ; le basculement automatique n\u00e9cessite repmgr.<br>La configuration comprend six parties mobiles qui doivent toutes \u00eatre correctes : la configuration de PostgreSQL, la configuration de repmgr, les cl\u00e9s SSH entre les utilisateurs postgres, le sudo sans mot de passe pour la gestion des services, les slots de r\u00e9plication, et repmgrd en cours d'ex\u00e9cution et non mis en pause.<br>Les points de d\u00e9faillance les plus courants sont les permissions du fichier sudoers (doivent \u00eatre 440, pas 644) et le fichier manquant <code>commande_arr\u00eat_service<\/code> pour les basculements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Une fois le cluster op\u00e9rationnel, la prochaine \u00e9tape consiste \u00e0 ajouter une adresse IP virtuelle flottante avec Keepalived afin que les applications se connectent toujours automatiquement au n\u0153ud principal actuel \u2014 voir <a href=\"https:\/\/rootfan.com\/fr\/postgresql-repmgr-avec-keepalived\/\">PostgreSQL repmgr avec Keepalived Ajout d'une VIP flottante<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Si vous construisez un cluster PostgreSQL haute disponibilit\u00e9 pour un environnement de production et que vous souhaitez un deuxi\u00e8me avis sur l'architecture avant de vous engager, <a href=\"https:\/\/rootfan.com\/fr\/services\/\">prendre contact \u2192<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>PostgreSQL n'inclut pas de basculement automatique d\u00e8s sa sortie de la bo\u00eete. Lorsque le primaire tombe en panne, quelqu'un doit promouvoir le r\u00e9plica manuellement \u2014 ce qui signifie des temps d'arr\u00eat. repmgr ajoute un d\u00e9mon de basculement automatique (repmgrd) qui surveille le cluster et promeut le r\u00e9plica en quelques secondes lorsque le primaire \u00e9choue. Ce guide vous guide dans la configuration d'un cluster PostgreSQL 18 \u00e0 deux n\u0153uds\u2026 <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/rootfan.com\/fr\/postgresql-repmgr-setup\/\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de \u00ab\u00a0Configuration de la r\u00e9plication PostgreSQL repmgr avec basculement automatique\u00a0\u00bb<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":6864,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_focus_keyword":"postgresql repmgr automatic failover","rank_math_title":"%title% %sep% %sitename%","rank_math_description":"Step-by-step guide to setting up a two-node PostgreSQL 18 cluster with streaming replication and automatic failover using repmgr 5.x on Ubuntu 24.04. Includes common pitfalls and how to avoid them.","rank_math_robots":"","rank_math_og_title":"","rank_math_og_description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[126],"tags":[127,81],"class_list":["post-6863","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-postgresql","tag-architecture","tag-step-by-step"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/rootfan.com\/wp-content\/uploads\/pexels-photo-37455405.jpeg?fit=975%2C1300&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/posts\/6863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/comments?post=6863"}],"version-history":[{"count":5,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/posts\/6863\/revisions"}],"predecessor-version":[{"id":6881,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/posts\/6863\/revisions\/6881"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/media\/6864"}],"wp:attachment":[{"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/media?parent=6863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/categories?post=6863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/tags?post=6863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}