Sun Cluster Data Service for PostgreSQL Guide for Solaris OS

Specifying the Parameters for the Rolechanger Resource.

Sun Cluster HA for PostgreSQL provides a script that automates the process of configuring the PostgreSQL Rolechanger resource. This script obtains configuration parameters from the rolechg_config file. A template for this file is in the /opt/SUNWscPostgreSQL/rolechg/util directory. To specify configuration parameters for the PostgreSQL resource, copy the rolechg_config file to another directory and edit the file.

Each configuration parameter in the rolechg_config file is defined as a keyword-value pair. The rolechg_config file already contains the required keywords and equals signs. For more information, see the Listing of rolechg_config. When you edit the /myplace/rolechg_config file, add the required value to each keyword.

The keyword-value pairs in the rolechg_config file are as follows:

RS=Rolechanger-resource-name
RG=Rolechanger-resource-group
PORT=80
LH=Rolechanger-logical-host
HAS_RS=Rolechanger-dependency-list
STDBY_RS=PostgreSQL-standby-resource-name
PRI_RS=PostgreSQL-primary-resource-name
STDBY_HOST=PostgreSQL-standby-hostname
STDBY_PFILE=PostgreSQL-standby-parameter-file
TRIGGER=PostgreSQL-pg_standby-trigger-file
WAIT=Seconds-before-trigger

The permitted values of the keywords rolechg_config and their explanation are as follows:

RS=Rolechanger-resource-name

Specifies the name assigned to the Rolechanger resource. You must specify a value for this keyword.

RG=Rolechanger-resource-group

Specifies the name assigned to the Rolechanger resource group. You must specify a value for this keyword.

PORT=80

In a global zone configuration, specifies the value of a dummy port only if you specified the LH value for the Rolechanger resource. This variable is used only during registration.

LH=Rolechanger-logical-host

In a global zone configuration, specifies the name of the SUNW.LogicalHostName resource for the Rolechanger resource.

HAS_RS=Rolechanger-dependency-list

Specifies the dependency list for the Rolchanger resource. If you have only the Rolechanger resource and the logical host in your resource group, omit this value.

STDBY_RS=PostgreSQL-standby-resourse-name

Specifies the name assigned to the PostgreSQL standby resource. You must specify a value for this keyword.

PRI_RS=PostgreSQL-primary-resourse-name

Specifies the name of the PostgreSQL primary resource. You must specify a value for this keyword.

STDBY_HOST=PostgreSQL-standby-hostname

Specifies the name of the host running the PostgreSQL standby resource group. You must specify a value for this keyword.

STDBY_PFILE=PostgreSQL-standby-parameter-file

Specifies the name of the PostgreSQL standby resource parameter file. You must specify a value for this keyword on the primary if you configure WAL file shipping as a replacement for shared storage.

TRIGGER=PostgreSQL-pg_standby-trigger-file

Specifies the trigger file for the PostgreSQL pg_standby utility. The trigger file must be an absolute path to a file name. You must specify a value for this keyword.

WAIT=Seconds-before-trigger

Specifies the number of seconds to wait before touching the trigger file, which starts the conversion from a standby to a primary. You must specify a value for this keyword.

The Rolechanger component of the PostgreSQL agent delivers two resilver scripts in the /opt/SUNWscPostgreSQL/rolecht/util directory. The scripts are called resilver-step1 and resilver-step2. The PostgreSQL user needs to copy, modify, and execute these scripts. The purpose of these scripts is to automate an exact copy from the standby to the primary after a failover. These scripts should incur a minimal amount of downtime, and provide a maximum amount of guidance.

The scripts rely on certain assumptions for the PostgreSQL configuration to work. You need to prepare your PostgreSQL installation according to the following assumptions:

When a recovery.conf file exists in the PGDATA directory, PostgreSQL executes the command specified in this file to obtain the WAL logs for its recovery. After finishing the recovery, PostgreSQL renames the file recovery.conf to recovery.done. To make the WAL file shipping and resilver scripts work properly, and for any other type of resilvering you might implement, you need to perform two steps. You have to create a link recovery.conf on the designated standby and a link recovery.done on the designated primary from your PGDATA directory to ../conf/recovery.conf.

The following examples show the different PostgreSQL configurations on the designated primary and standby servers. The designated primary and standby servers have different archive and recovery commands. In Example 4, the resilvering scripts are also explained in detail.


Example 3 Example for the Designated Primary

This example shows the required archive and recovery configuration for the designated primary server.

The archive command in postgresql.conf:


archive_command = '/usr/local/bin/rsync -arv %p \
standby:/pgs/82_walarchives/%f</dev/null'

The contents of recovery.conf/done:


restore_command = 'cp /pgs/82_walarchives/%f %p'


Example 4 Example for the Designated Standby

This example shows the required archive, recovery, and resilver configuration for the designated standby server.

The archive command in postgresql.conf:


archive_command = '/usr/local/bin/rsync -arv %p standby:/pgs/ \
82_walarchives/%f</dev/null'

The contents of recovery.conf/done:


restore_command = '/pgs/postgres-8.2.5/bin/pg_standby -k 10 -t \
/pgs/data/failover /pgs/82_walarchives %f %p'

The two scripts have various variables that need to be customized. The key-value pair and explanation for the two scripts are as follows:

Explanation for the script resilver-step1

SOURCE_DATA=PGDATA of the standby

Specifies the PGDATA directory of the current node. For normal use, it would be the one on the designated standby node.

TARGET_DATA=PGDATA of the primary

Specifies the PGDATA of the target node. For normal use, it would be the one on the designated primary node.

TARGET=Primary-host

Specifies the name of the target node. For normal use, it would be the name of the designated primary node.

PGS_BASE=/pgs/postgres-8.2.5 for a custom-built PostgreSQL or /usr/postgres/8.2 for PostgreSQL delivered with Solaris 10

Specifies the PostgreSQL base directory, where the PostgreSQL binaries are located.

PRI_GRP=primary-rg

Specifies the resource group, which contains the cluster resource of the designated primary.

STDBY_GRP=standby-rg

Specifies the resource group, which contains the cluster resource of the designated standby.

STDBY_RS=standby-rs

Specifies the resource name of the designated standby.

PGPORT=5432

Specifies the database port.

ROLECHG_GRP=rolechg-rg

Specifies the resource group, which contains the Rolechanger resource.

RSYNC=/usr/local/bin/rsync -rav

Specifies the absolute path to the RSYNC command including the necessary options.

SSH_PASSPHRASE=false

Specifies whether your passphrase is secure.

Explanation for the script resilver-step2

SOURCE=Standby-host

Specifies the name of the source node. For normal use, it would be the name of the designated standby node.

SOURCE_DATA=PGDATA of the standby

Specifies the PGDATA directory of the current node. For normal use, it would be the name of the designated standby node.

TARGET_DATA=PGDATA of the primary

Specifies the PGDATA of the target node. For normal use, it would be the name of the designated primary node.

TARGET=Primary-host

Specifies the name of the target node. For normal use, it would be the name of the designated primary node.

PGS_BASE=/pgs/postgres-8.2.5 for a custom build PostgreSQL or /usr/postgres/8.2 for PostgreSQL delivered with Solaris 10

Specifies the PostgreSQL base directory, where the PostgreSQL binaries are located.

PRI_GRP=primary-rg

Specifies the resource group, which contains the cluster resource of the designated primary.

STDBY_GRP=standby-rg

Specifies the resource group, which contains the cluster resource of the designated standby.

STDBY_RS=standby-rs

Specifies the resource name of the designated standby resource. This name should be unique on your standby. The script resilver-step2 requires this file generated by the script resilver-step1 under /var/tmp/${STDBY_RS}-resilver.

ROLECHG_GRP=rolechg-rg

Specifies the resource group, which contains the Rolechanger resource.

PRI_NODE=primary-host:primary-zone

Specifies the node name or zone name of the designated primary host or zone.

RSYNC=/usr/local/bin/rsync -rav

Specifies the absolute path to RSYNC command including the necessary options.

SSH_PASSPHRASE=false

Specifies whether your ssh key is secured by a passphrase or not.