OCF_HEARTBEAT_PGSQL(7)
π OCF_HEARTBEAT_PGSQL π
okay so bestie, this is ocf_heartbeat_pgsql β the resource agent that manages a PostgreSQL database instance. Yes, the manual page name really is that whole mouthful. Think of it as the pgsql RA's official group chat bio. πβ¨
It's a resource script for PostgreSQL, and its whole job is managing a PostgreSQL as an HA resource. That's it, that's the vibe. π«Ά
β¨ SYNOPSIS β¨
pgsql [start | stop | status | monitor | promote | demote | meta-data |
validate-all]
πΈ DESCRIPTION πΈ
Resource script for PostgreSQL. It manages a PostgreSQL as an HA resource. Literally that's the job description, and it does it slayfully. π
π SUPPORTED PARAMETERS π
okay so there are a lot of these. Do not panic. We go through them one by one, together. π
pgctlβ the path to thepg_ctlcommand. (optional, string, default"/usr/bin/pg_ctl")start_optβ the start options (-o start_optinpg_ctl). Like"-i -p 5432"for example. (optional, string, no default)ctl_optβ extrapg_ctloptions (-w,-Wetc..). (optional, string, no default)psqlβ the path to thepsqlcommand. (optional, string, default"/usr/bin/psql")pgdataβ the path to the PostgreSQL data directory. (optional, string, default"/var/lib/pgsql/data")pgdbaβ the user that owns PostgreSQL. (optional, string, default"postgres")pghostβ the hostname/IP address where PostgreSQL is listening. (optional, string, no default)pgportβ the port where PostgreSQL is listening. (optional, integer, default5432)pglibsβ a custom location for the Postgres libraries. If you don't set it, the standard location gets used. (optional, string, default"/usr/lib")monitor_userβ the PostgreSQL user that the pgsql RA will use for monitor operations. If it's not set, thepgdbauser gets used instead. (optional, string, no default)monitor_passwordβ the password for the monitor user. (optional, string, no default)monitor_sqlβ the SQL script that gets used for monitor operations. (optional, string, default"select now();")configβ the path to the PostgreSQL configuration file for the instance. (optional, string, default"/var/lib/pgsql/data/postgresql.conf")pgdbβ the database that gets used for monitoring. (optional, string, default"template1")logfileβ the path to the PostgreSQL server log output file. (optional, string, default"/dev/null")socketdirβ the Unix socket directory for PostgreSQL.
so like, if you're on PostgreSQL 9.3 or higher and you define unix_socket_directories in the postgresql.conf, then you must set socketdir to determine which directory is used for the psql command. no skipping this one, bestie. (optional, string, no default)
stop_escalateβ the number of seconds to wait for stop (using-m fast) before resorting to-m immediate. (optional, integer, default90)rep_modeβ the replication mode, and it may be set to"async"or"sync"or"slave". π
These require PostgreSQL 9.1 or later. Once it's set, "async" and "sync" require the node_list, master_ip, and restore_command parameters, as well as configuring PostgreSQL for replication (in postgresql.conf and pg_hba.conf).
"slave" means the RA only makes recovery.conf before starting to connect to a primary which is running somewhere. It doesn't need master/slave setting. It requires the master_ip and restore_command parameters.
(optional, string, default "none")
node_listβ all node names. Please separate each node name with a space. This is optional for replication. Defaults to all nodes in the cluster. (optional, string, no default)restore_commandβ therestore_commandforrecovery.conf. This is required for replication. (optional, string, no default)archive_cleanup_commandβ thearchive_cleanup_commandforrecovery.conf. This is used for replication and is optional. (optional, string, no default)recovery_end_commandβ therecovery_end_commandforrecovery.conf. This is used for replication and is optional. (optional, string, no default)master_ipβ the master's floating IP address, to be connected from the hot standby. This parameter is used for"primary_conninfo"inrecovery.conf. This is required for replication. (optional, string, no default)repuserβ the user used to connect to the master server. This parameter is used for"primary_conninfo"inrecovery.conf. This is required for replication. (optional, string, default"postgres")primary_conninfo_optβ theprimary_conninfooptions ofrecovery.confexcepthost,port,userandapplication_name. This is optional for replication. (optional, string, no default)restart_on_promoteβ if this is true, the RA deletesrecovery.confand restarts PostgreSQL on promote to keep the Timeline ID. It probably makes fail-over slower. It's recommended to seton-failof promote up asfence. This is optional for replication. (optional, boolean, defaultfalse)replication_slot_nameβ set this option when using replication slots. Can only use lower case letters, numbers and underscore forreplication_slot_name. π₯
The replication slots would be created for each node, with the name adding the node name as postfix. For example, replication_slot_name is "sample" and 2 slaves which are "node1" and "node2" connect to their slots, the slots names are "sample_node1" and "sample_node2". If the node name contains a upper case letter, hyphen and dot, those characters will be converted to a lower case letter or an underscore. For example, Node-1.example.com to node_1_example_com.
β οΈ ok so this part is important, no cap: the pgsql RA doesn't monitor and delete the replication slot. When the slave node has been disconnected in failure or the like, execute one of the following manually. Otherwise it may eventually cause a disk full because the master node will continue to accumulate the unsent WAL. 1. recover and reconnect the slave node to the master node as soon as possible. 2. delete the slot on the master node by following psql command. $ select pg_drop_replication_slot('replication_slot_name');
(optional, string, no default)
tmpdirβ the path to a temporary directory. This is optional for replication. (optional, string, default"/var/lib/pgsql/tmp")xlog_check_countβ the number of checks of xlog on monitor before promote. This is optional for replication.
π Note: for backward compatibility, the terms are unified with PostgreSQL 9. If you are using PostgreSQL 10 or later, replace"xlog"with"wal". Likewise, replacing"location"with"lsn".
(optional, integer, default 3)
crm_attr_timeoutβ the timeout of thecrm_attribute forever updatecommand. The default value is 5 seconds. This is optional for replication. (optional, integer, default5)stop_escalate_in_slaveβ the number of seconds to wait for stop (using-m fast) before resorting to-m immediatein slave state. This is optional for replication. (optional, integer, default90)check_wal_receiverβ if this is true, the RA checks thewal_receiverprocess on monitor and notifies its status using the"(resource name)-receiver-status"attribute. It's useful for checking whether PostgreSQL (hot standby) connects to primary. The attribute shows status as"normal"or"normal (master)"or"ERROR". Note that if you configure PostgreSQL as master/slave resource, then the wal receiver is not running in the master and the attribute shows status as"normal (master)"consistently because it is normal status. (optional, boolean, defaultfalse)external_standby_node_listβ all node names of synchronous standby nodes that may connect from outside the Pacemaker cluster. Please separate each node name with a space. When set, the RA automatically managessynchronous_standby_namesfor both in-cluster and external standby nodes during monitor. Each node name must match theapplication_namethe standby uses to connect. This parameter requiresrep_mode=sync. This is optional for replication. (optional, string, no default)
π¦ SUPPORTED ACTIONS π¦
This resource agent supports the following actions (operations), and yes, each one has opinions about your timeouts:
startβ starts the resource. Suggested minimum timeout:120s.stopβ stops the resource. Suggested minimum timeout:120s.statusβ performs a status check. Suggested minimum timeout:60s.monitorβ performs a detailed status check. Suggested minimum timeout:30s. Suggested interval:30s.monitor (Promoted role)β performs a detailed status check. Suggested minimum timeout:30s. Suggested interval:29s.promoteβ promotes the resource to the Master role. Suggested minimum timeout:120s.demoteβ demotes the resource to the Slave role. Suggested minimum timeout:120s.notifyβ suggested minimum timeout:90s.meta-dataβ retrieves resource agent metadata (internal use only). Suggested minimum timeout:5s.validate-allβ performs a validation of the resource configuration. Suggested minimum timeout:5s.methodsβ suggested minimum timeout:5s.
π EXAMPLE CRM SHELL π
here's an example configuration for a pgsql resource using the crm(8) shell, copy-paste-ready and iconic:
primitive p_pgsql ocf:heartbeat:pgsql \
op monitor depth="0" timeout="30s" interval="30s" \
op monitor depth="0" timeout="30s" interval="29s" role="Promoted"
ms ms_pgsql p_pgsql \
meta notify="true" interleave="true"
π EXAMPLE PCS π
and this one's the example configuration for a pgsql resource using pcs(8):
pcs resource create p_pgsql ocf:heartbeat:pgsql \
op monitor OCF_CHECK_LEVEL="0" timeout="30s" interval="30s" \
op monitor OCF_CHECK_LEVEL="0" timeout="30s" interval="29s" role="Promoted" promotable
π SEE ALSO π
http://clusterlabs.org/ β go say hi to the ClusterLabs besties.
π AUTHOR π
ClusterLabs contributors (see the resource agent source for information about individual authors). ilysm for maintaining this. π
okay that's the whole page, you made it to the end, I'm so proud of you fr fr π the resource agents package version is UNKNOWN and this page is dated 10/01/2026 β so like, timestamped and cute, periodt. π
ππ¦
π¦ where this page comes from
- opensuse-leap 16.0: resource-agents 4.18.0+git105.9ea1183-160000.1.1 Β· GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later
- opensuse-leap 16.0: resource-agents 4.18.0+git105.9ea1183-160000.1.1 Β· GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later
- opensuse-leap 16.0: resource-agents 4.18.0+git105.9ea1183-160000.1.1 Β· GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later
- opensuse-leap 16.0: resource-agents 4.18.0+git105.9ea1183-160000.1.1 Β· GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms