PG_AUTOCTL DISABLE MONITOR(1)

πŸ’– PG_AUTOCTL DISABLE MONITOR(1) πŸ’–

okay bestie, welcome to pg_autoctl disable monitor β€” the pg_autoctl manual page for turning the monitor off for a node. yes, that's the whole vibe. let's go ✨


🌸 NAME 🌸

pg_autoctl disable monitor β€” pg_autoctl disable monitor

pg_autoctl disable monitor β€” disable the monitor for this node

so like, it's the command, and it does the thing, and the thing is turning off the monitor for this node. iconic, no notes πŸ’…


✨ SYNOPSIS ✨

okay so the tea is: you can totally disable the pg_auto_failover monitor and then enable it again, online, on a pg_autoctl Postgres node that's already running. no downtime drama, no restarting anything πŸŽ€

and when is this actually useful?? the main use-cases are when the monitor node has to be replaced β€” either after a full crash of the old monitor node, or when you're migrating to a brand new monitor node (think: hardware replacement, region or zone migration, etc). glow-up for your monitor, fr fr πŸ¦‹

usage: pg_autoctl disable monitor  [ --pgdata --force ]

--pgdata      path to data directory
--force       force unregistering from the monitor

πŸ’… OPTIONS πŸ’…

  • --pgdata β€” where's the Postgres node you're managing locally? this is it. it defaults to the environment variable PGDATA. oh and pssst: use --monitor if you wanna connect to a monitor from literally anywhere, instead of using the monitor URI that a local Postgres node managed with pg_autoctl would use. flexibility, we love her πŸ‘‘
  • --force β€” okay so --force is covering two situations, and here they are:
    1. by default, the command expects to be able to connect to the current monitor. so when the current known monitor in the setup isn't running anymore, use --force to skip that step. no monitor? no problem πŸ’€
    2. when pg_autoctl could connect to the monitor and the node is found there, that's normally an error that stops you from disabling the monitor. using --force lets the command drop the node from the monitor and then keep going with disabling the monitor. breaking up with the monitor, but politely 🫢

🌈 ENVIRONMENT 🌈

  • PGDATA β€” Postgres directory location. can be used instead of the --pgdata option. same energy, fewer flags ✨
  • PG_AUTOCTL_MONITOR β€” Postgres URI to connect to the monitor node. can be used instead of the --monitor option πŸ’œ
  • XDG_CONFIG_HOME β€” the pg_autoctl command stores its configuration files in the standard place XDG_CONFIG_HOME. see the XDG Base Directory Specification πŸ“
  • XDG_DATA_HOME β€” the pg_autoctl command stores its internal states files in the standard place XDG_DATA_HOME, which defaults to ~/.local/share. see the XDG Base Directory Specification πŸ“βœ¨

πŸŽ€ EXAMPLES πŸŽ€

first, let's see what the state of the world is:

$ pg_autoctl show state
    Name |  Node |      Host:Port |       LSN |   Connection |       Current State |      Assigned State
------+-------+----------------+-----------+--------------+---------------------+--------------------
node1 |     1 | localhost:5501 | 0/4000148 |   read-write |             primary |             primary
node2 |     2 | localhost:5502 | 0/4000148 |    read-only |           secondary |           secondary
node3 |     3 | localhost:5503 | 0/4000148 |    read-only |           secondary |           secondary

okay now watch what happens when we try to disable the monitor on node3 without --force:

$ pg_autoctl disable monitor --pgdata node3
12:41:21 43039 INFO  Found node 3 "node3" (localhost:5503) on the monitor
12:41:21 43039 FATAL Use --force to remove the node from the monitor

yeahhh, FATAL. it found the node and said "bestie, you need --force for that." 😭

so let's do it with --force:

$ pg_autoctl disable monitor --pgdata node3 --force
12:41:32 43219 INFO  Removing node 3 "node3" (localhost:5503) from monitor

and now the state, which is giving... node3 is gone:

$ pg_autoctl show state
 Name |  Node |      Host:Port |       LSN |   Connection |       Current State |      Assigned State
------+-------+----------------+-----------+--------------+---------------------+--------------------
node1 |     1 | localhost:5501 | 0/4000760 |   read-write |             primary |             primary
node2 |     2 | localhost:5502 | 0/4000760 |    read-only |           secondary |           secondary

πŸ‘‘ AUTHOR πŸ‘‘

Microsoft


Copyright (c) Microsoft Corporation. All rights reserved.


and that's the whole page, bestie!! 🫢 this was pg_auto_failover version 2.2, dated Apr 07, 2025, straight from the PG_AUTOCTL DISABLE MONITOR(1) manual. go forth and disable that monitor responsibly πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from