OCF_HEARTBEAT_PGSQLMS(7)

πŸ“¦
version 2.3.0 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu questing

πŸ’… OCF_HEARTBEAT_PGSQLMS(7) β€” ok so bestie, let's talk about ocf_heartbeat_pgsqlms

It lives in the OCF resource agents manual, and honestly? It's the moment.


✨ NAME ✨

ocf_heartbeat_pgsqlms β€” a PostgreSQL multi-state resource agent for Pacemaker. Periodt.


πŸ¦‹ SYNOPSIS πŸ¦‹

pgsqlms [start | stop | monitor | promote | demote | notify | reload |
methods | meta-data | validate-all]

That's it, that's the whole vibe check.


🌸 DESCRIPTION 🌸

So basically: this is a resource script for PostgreSQL in replication. It manages PostgreSQL servers using streaming replication as an HA resource. The way it just... handles your failover?? Iconic. No cap.


πŸ’– SUPPORTED PARAMETERS πŸ’–

All of these are optional unless the vibes say otherwise. Let's get into it.

  • pgdata β€” where your instance's PGDATA actually lives. (optional, string, default "/var/lib/pgsql/data")
  • pghost β€” the socket directory or IP address you use to connect to the local instance. (optional, string, default "/var/run/postgresql")
  • pgport β€” the port for connecting to the local instance. (optional, integer, default "5432")
  • bindir β€” where the PostgreSQL binaries are chilling. (optional, string, default "/usr/bin")
  • system_user β€” the system owner of your instance's process, aka who runs this thing. (optional, string, default "postgres")
  • recovery_template β€” ONLY for PostgreSQL 11 and bellow. This is the local template that gets copied as the "PGDATA/recovery.conf" file, and this template file must exist on all nodes. And like... with PostgreSQL 12 and higher? The cluster will straight up refuse to start if this parameter is set or if a template file is found. So don't be messy. (optional, string, default "$PGDATA/recovery.conf.pcmk")
  • maxlag β€” the maximum lag allowed on a standby before we set a negative master score on it. The math is based on the difference between the current xlog location on the master and the write location on the standby. (optional, integer, default "0" disables this feature)
  • datadir β€” path to the directory set in "data_directory" from your postgresql.conf file. This parameter has the same default as PostgreSQL itself: the value of the "pgdata" parameter. Unless you have a super special PostgreSQL setup and you genuinely understand this parameter, ignore it. fr fr. (optional, string, default to the value of "pgdata")
  • start_opts β€” extra arguments handed to the postgres process on startup. Peep "postgres --help" for the available options. Super useful when the postgresql.conf file isn't in the data directory (PGDATA), eg.:
-c config_file=/etc/postgresql/9.3/main/postgresql.conf

(optinal, string, default "")


πŸ‘‘ SUPPORTED ACTIONS πŸ‘‘

This resource agent supports the following actions (operations):

  • start β€” starts the resource. Suggested minimum timeout: 60.
  • stop β€” stops the resource. Suggested minimum timeout: 60.
  • reload β€” Suggested minimum timeout: 20.
  • promote β€” promotes the resource to the Master role. Suggested minimum timeout: 30.
  • demote β€” demotes the resource to the Slave role. Suggested minimum timeout: 120.
  • monitor (Master role) β€” performs a detailed status check. Suggested minimum timeout: 10. Suggested interval: 15.
  • monitor (Slave role) β€” performs a detailed status check. Suggested minimum timeout: 10. Suggested interval: 16.
  • notify β€” Suggested minimum timeout: 60
  • meta-data β€” retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5.
  • methods β€” Suggested minimum timeout: 5.
  • validate-all β€” performs a validation of the resource configuration. Suggested minimum timeout: 5.

πŸŽ€ EXAMPLE CRM SHELL πŸŽ€

Here's an example config for a pgsqlms resource using the crm(8) shell, and yes it's a whole meal:

primitive pgsqld pgsqlms                                                 \
  params pgdata="/var/lib/postgresql/9.6/main"                           \
    bindir="/usr/lib/postgresql/9.6/bin"                                 \
    pghost="/var/run/postgresql"                                         \
    recovery_template="/etc/postgresql/9.6/main/recovery.conf.pcmk"      \
    start_opts="-c config_file=/etc/postgresql/9.6/main/postgresql.conf" \
  op start timeout=60s                                                   \
  op stop timeout=60s                                                    \
  op promote timeout=30s                                                 \
  op demote timeout=120s                                                 \
  op monitor interval=15s timeout=10s role="Master"                      \
  op monitor interval=16s timeout=10s role="Slave"                       \
  op notify timeout=60s

ms pgsql-ha pgsqld meta notify=true

🧚 EXAMPLE PCS 🧚

And here's the same energy with pcs(8):

pcs resource create pgsqld ocf:heartbeat:pgsqlms            \
  bindir=/usr/pgsql-9.6/bin pgdata=/var/lib/pgsql/9.6/data  \
  op start timeout=60s                                      \
  op stop timeout=60s                                       \
  op promote timeout=30s                                    \
  op demote timeout=120s                                    \
  op monitor interval=15s timeout=10s role="Master"         \
  op monitor interval=16s timeout=10s role="Slave"          \
  op notify timeout=60s --master notify=true

πŸ”₯ SEE ALSO πŸ”₯


πŸ’œ AUTHOR πŸ’œ

Jehan-Guillaume de Rorthais and Mael Rimbault. Legends, honestly. 🫢


ok that's the whole page, you ate that πŸ“ go configure something beautiful πŸ’…

Version 2.3.0 β€” dated 2024-03-18 β€” from the OCF resource agents manual. Mwah. πŸ’–

πŸ“¦ where this page comes from