'\" t .\" Title: ocf_heartbeat_pgsql .\" Author: ClusterLabs contributors (see the resource agent source for information about individual authors) .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 12/17/2020 .\" Manual: OCF resource agents .\" Source: resource-agents UNKNOWN .\" Language: English .\" .TH "OCF_HEARTBEAT_PGSQL" "7" "12/17/2020" "resource-agents UNKNOWN" "OCF resource agents" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" ocf_heartbeat_pgsql \- Manages a PostgreSQL database instance .SH "SYNOPSIS" .HP \w'\fBpgsql\fR\ 'u \fBpgsql\fR [start | stop | status | monitor | promote | demote | meta\-data | validate\-all] .SH "DESCRIPTION" .PP Resource script for PostgreSQL\&. It manages a PostgreSQL as an HA resource\&. .SH "SUPPORTED PARAMETERS" .PP \fBpgctl\fR .RS 4 Path to pg_ctl command\&. .sp (optional, string, default "/usr/bin/pg_ctl") .RE .PP \fBstart_opt\fR .RS 4 Start options (\-o start_opt in pg_ctl)\&. "\-i \-p 5432" for example\&. .sp (optional, string, no default) .RE .PP \fBctl_opt\fR .RS 4 Additional pg_ctl options (\-w, \-W etc\&.\&.)\&. .sp (optional, string, no default) .RE .PP \fBpsql\fR .RS 4 Path to psql command\&. .sp (optional, string, default "/usr/bin/psql") .RE .PP \fBpgdata\fR .RS 4 Path to PostgreSQL data directory\&. .sp (optional, string, default "/var/lib/pgsql/data") .RE .PP \fBpgdba\fR .RS 4 User that owns PostgreSQL\&. .sp (optional, string, default "postgres") .RE .PP \fBpghost\fR .RS 4 Hostname/IP address where PostgreSQL is listening .sp (optional, string, no default) .RE .PP \fBpgport\fR .RS 4 Port where PostgreSQL is listening .sp (optional, integer, default 5432) .RE .PP \fBpglibs\fR .RS 4 Custom location of the Postgres libraries\&. If not set, the standard location will be used\&. .sp (optional, string, default "/usr/lib") .RE .PP \fBmonitor_user\fR .RS 4 PostgreSQL user that pgsql RA will user for monitor operations\&. If it\*(Aqs not set pgdba user will be used\&. .sp (optional, string, no default) .RE .PP \fBmonitor_password\fR .RS 4 Password for monitor user\&. .sp (optional, string, no default) .RE .PP \fBmonitor_sql\fR .RS 4 SQL script that will be used for monitor operations\&. .sp (optional, string, default "select now();") .RE .PP \fBconfig\fR .RS 4 Path to the PostgreSQL configuration file for the instance\&. .sp (optional, string, default "/var/lib/pgsql/data/postgresql\&.conf") .RE .PP \fBpgdb\fR .RS 4 Database that will be used for monitoring\&. .sp (optional, string, default "template1") .RE .PP \fBlogfile\fR .RS 4 Path to PostgreSQL server log output file\&. .sp (optional, string, default "/dev/null") .RE .PP \fBsocketdir\fR .RS 4 Unix socket directory for PostgreSQL\&. .sp If you use PostgreSQL 9\&.3 or higher and define unix_socket_directories in the postgresql\&.conf, then you must set socketdir to determine which directory is used for psql command\&. .sp (optional, string, no default) .RE .PP \fBstop_escalate\fR .RS 4 Number of seconds to wait for stop (using \-m fast) before resorting to \-m immediate .sp (optional, integer, default 90) .RE .PP \fBrep_mode\fR .RS 4 Replication mode may be set to "async" or "sync" or "slave"\&. They require PostgreSQL 9\&.1 or later\&. Once set, "async" and "sync" require node_list, master_ip, and restore_command parameters,as well as configuring PostgreSQL for replication (in postgresql\&.conf and pg_hba\&.conf)\&. .sp "slave" means that RA only makes recovery\&.conf before starting to connect to primary which is running somewhere\&. It doesn\*(Aqt need master/slave setting\&. It requires master_ip restore_command parameters\&. .sp (optional, string, default "none") .RE .PP \fBnode_list\fR .RS 4 All node names\&. Please separate each node name with a space\&. This is optional for replication\&. Defaults to all nodes in the cluster .sp (optional, string, no default) .RE .PP \fBrestore_command\fR .RS 4 restore_command for recovery\&.conf\&. This is required for replication\&. .sp (optional, string, no default) .RE .PP \fBarchive_cleanup_command\fR .RS 4 archive_cleanup_command for recovery\&.conf\&. This is used for replication and is optional\&. .sp (optional, string, no default) .RE .PP \fBrecovery_end_command\fR .RS 4 recovery_end_command for recovery\&.conf\&. This is used for replication and is optional\&. .sp (optional, string, no default) .RE .PP \fBmaster_ip\fR .RS 4 Master\*(Aqs floating IP address to be connected from hot standby\&. This parameter is used for "primary_conninfo" in recovery\&.conf\&. This is required for replication\&. .sp (optional, string, no default) .RE .PP \fBrepuser\fR .RS 4 User used to connect to the master server\&. This parameter is used for "primary_conninfo" in recovery\&.conf\&. This is required for replication\&. .sp (optional, string, default "postgres") .RE .PP \fBprimary_conninfo_opt\fR .RS 4 primary_conninfo options of recovery\&.conf except host, port, user and application_name\&. This is optional for replication\&. .sp (optional, string, no default) .RE .PP \fBrestart_on_promote\fR .RS 4 If this is true, RA deletes recovery\&.conf and restarts PostgreSQL on promote to keep Timeline ID\&. It probably makes fail\-over slower\&. It\*(Aqs recommended to set on\-fail of promote up as fence\&. This is optional for replication\&. .sp (optional, boolean, default false) .RE .PP \fBreplication_slot_name\fR .RS 4 Set this option when using replication slots\&. Can only use lower case letters, numbers and underscore for replication_slot_name\&. .sp 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\&. .sp pgsql RA doesn\*(Aqt 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(\*(Aqreplication_slot_name\*(Aq); .sp (optional, string, no default) .RE .PP \fBtmpdir\fR .RS 4 Path to temporary directory\&. This is optional for replication\&. .sp (optional, string, default "/var/lib/pgsql/tmp") .RE .PP \fBxlog_check_count\fR .RS 4 Number of checks of xlog on monitor before promote\&. This is optional for replication\&. .sp 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"\&. .sp (optional, integer, default 3) .RE .PP \fBcrm_attr_timeout\fR .RS 4 The timeout of crm_attribute forever update command\&. Default value is 5 seconds\&. This is optional for replication\&. .sp (optional, integer, default 5) .RE .PP \fBstop_escalate_in_slave\fR .RS 4 Number of seconds to wait for stop (using \-m fast) before resorting to \-m immediate in slave state\&. This is optional for replication\&. .sp (optional, integer, default 90) .RE .PP \fBcheck_wal_receiver\fR .RS 4 If this is true, RA checks wal_receiver process on monitor and notifies its status using "(resource name)\-receiver\-status" attribute\&. It\*(Aqs 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 wal receiver is not running in the master and the attribute shows status as "normal (master)" consistently because it is normal status\&. .sp (optional, boolean, default false) .RE .SH "SUPPORTED ACTIONS" .PP This resource agent supports the following actions (operations): .PP \fBstart\fR .RS 4 Starts the resource\&. Suggested minimum timeout: 120s\&. .RE .PP \fBstop\fR .RS 4 Stops the resource\&. Suggested minimum timeout: 120s\&. .RE .PP \fBstatus\fR .RS 4 Performs a status check\&. Suggested minimum timeout: 60s\&. .RE .PP \fBmonitor\fR .RS 4 Performs a detailed status check\&. Suggested minimum timeout: 30s\&. Suggested interval: 30s\&. .RE .PP \fBmonitor (Master role)\fR .RS 4 Performs a detailed status check\&. Suggested minimum timeout: 30s\&. Suggested interval: 29s\&. .RE .PP \fBpromote\fR .RS 4 Promotes the resource to the Master role\&. Suggested minimum timeout: 120s\&. .RE .PP \fBdemote\fR .RS 4 Demotes the resource to the Slave role\&. Suggested minimum timeout: 120s\&. .RE .PP \fBnotify\fR .RS 4 Suggested minimum timeout: 90s\&. .RE .PP \fBmeta\-data\fR .RS 4 Retrieves resource agent metadata (internal use only)\&. Suggested minimum timeout: 5s\&. .RE .PP \fBvalidate\-all\fR .RS 4 Performs a validation of the resource configuration\&. Suggested minimum timeout: 5s\&. .RE .PP \fBmethods\fR .RS 4 Suggested minimum timeout: 5s\&. .RE .SH "EXAMPLE CRM SHELL" .PP The following is an example configuration for a pgsql resource using the \fBcrm\fR(8) shell: .sp .if n \{\ .RS 4 .\} .nf primitive p_pgsql ocf:heartbeat:pgsql \e op monitor depth="0" timeout="30s" interval="30s" \e op monitor depth="0" timeout="30s" interval="29s" role="Master" .fi .if n \{\ .RE .\} .sp .if n \{\ .RS 4 .\} .nf ms ms_pgsql p_pgsql \e meta notify="true" interleave="true" .fi .if n \{\ .RE .\} .SH "EXAMPLE PCS" .PP The following is an example configuration for a pgsql resource using \fBpcs\fR(8) .sp .if n \{\ .RS 4 .\} .nf pcs resource create p_pgsql ocf:heartbeat:pgsql \e op monitor OCF_CHECK_LEVEL="0" timeout="30s" interval="30s" \e op monitor OCF_CHECK_LEVEL="0" timeout="30s" interval="29s" role="Master" promotable .fi .if n \{\ .RE .\} .SH "SEE ALSO" .PP \m[blue]\fB\%http://clusterlabs.org/\fR\m[] .SH "AUTHOR" .PP \fBClusterLabs contributors (see the resource agent source for information about individual authors)\fR