PG_AUTOCTL_ENABLE_MONITOR(1)

πŸ“¦
version 2.1 Β· 2 versions
, in fedora 43, fedora 44

πŸ’– pg_autoctl enable monitor πŸ’–

okay bestie, welcome to the pg_auto_failover manual, page PG_AUTOCTL_ENABLE_MONITOR(1). sit down, grab a strawberry πŸ“, we're talking about pg_autoctl enable monitor.


✨ NAME ✨

pg_autoctl enable monitor β€” pg_autoctl enable monitor

pg_autoctl enable monitor β€” turn on a monitor for this node so it gets orchestrated from there. iconic behaviour tbh


πŸŽ€ SYNOPSIS πŸŽ€

bestie, here's the tea: you can disable the pg_auto_failover monitor and then enable it again online in a running pg_autoctl Postgres node. no cap. the main use-cases where you'd wanna do this are when the monitor node has to be replaced β€” either after a full crash of the previous monitor node πŸ’€, or for migrating to a new monitor node (hardware replacement, region or zone migration, etc). very main character energy for your infra.

usage: pg_autoctl enable monitor  [ --pgdata --allow-failover ] postgres://autoctl_node@new.monitor.add.ress/pg_auto_failover

--pgdata      path to data directory

🌸 OPTIONS 🌸

  • --pgdata β€” where the Postgres node you're managing locally lives. defaults to the environment variable PGDATA. pro tip: use --monitor to connect to a monitor from anywhere, rather than the monitor URI that a local Postgres node managed with pg_autoctl is using. ✨

πŸ¦‹ ENVIRONMENT πŸ¦‹

  • PGDATA β€” Postgres directory location. you can use this instead of the --pgdata option. 🫢
  • PG_AUTOCTL_MONITOR β€” Postgres URI to connect to the monitor node, and you can use it 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 🧚

okay this is the part where it gets real. watch the glow-up:

$ 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

$ pg_autoctl enable monitor --pgdata node3 'postgres://autoctl_node@localhost:5500/pg_auto_failover?sslmode=require'
12:42:07 43834 INFO  Registered node 3 (localhost:5503) with name "node3" in formation "default", group 0, state "wait_standby"
12:42:07 43834 INFO  Successfully registered to the monitor with nodeId 3
12:42:08 43834 INFO  Still waiting for the monitor to drive us to state "catchingup"
12:42:08 43834 WARN  Please make sure that the primary node is currently running `pg_autoctl run` and contacting the monitor.

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

like?? node3 just showed up and slotted right in as a secondary. ate. πŸ’…

that WARN line is a real one tho β€” make sure the primary node is currently running pg_autoctl run and contacting the monitor, or nothing's gonna drive you anywhere. no thoughts head empty is not a valid replication strategy bestie 😭

πŸ‘‘ AUTHOR πŸ‘‘

Microsoft


Copyright (c) Microsoft Corporation. All rights reserved.


and that's the whole page, bestie! πŸŽ€ this was pg_auto_failover version 2.1, dated Jan 18, 2025, page PG_AUTOCTL_ENABLE_MONITOR(1) β€” go enable that monitor, you've got this. πŸ¦‹βœ¨

πŸ“¦ where this page comes from