OCF_HEARTBEAT_PGSQLMS(7)
π
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'sPGDATAactually 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 yourpostgresql.conffile. 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 thepostgresql.conffile 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: 60meta-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
- debian trixie: resource-agents-paf 2.3.0-2 Β· PostgreSQL
- ubuntu noble: resource-agents-paf 2.3.0-2 Β· PostgreSQL
- ubuntu questing: resource-agents-paf 2.3.0-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms