JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Cluster Data Service for PostgreSQL Guide     Oracle Solaris Cluster 4.1
search filter icon
search icon

Document Information

Preface

1.  Installing and Configuring HA for PostgreSQL

HA for PostgreSQL Overview

Overview of Installing and Configuring HA for PostgreSQL

Planning the HA for PostgreSQL Installation and Configuration

PostgreSQL and Oracle Solaris Zones

PostgreSQL WAL Shipping

Configuration Restrictions

Restriction for the Location of the Database Cluster

Restriction for the Listening Policy of the PostgreSQL Database Server

Restriction for the PostgreSQL postgresql.conf File

Restriction for the Password Policy for the HA for PostgreSQL Monitoring Database

Restriction for the PostgreSQL smf Service Name in an HA for Solaris Zones Configuration

Restriction for the PostgreSQL WAL File Shipping Without Shared Storage

Configuration Requirements

Dependencies Between HA for PostgreSQL Components

Parameter File for HA for PostgreSQL

Configuration Requirements for the WAL File Shipping Without Shared Storage Configuration

Installing and Configuring PostgreSQL

How to Enable a PostgreSQL Database to Run in the Global Zone

How to Install and Configure PostgreSQL in the Global Zone

How to Enable a Non-Global Zone to Run PostgreSQL in an HA for Solaris Zones Configuration

How to Install and Configure PostgreSQL in an HA for Solaris Zones Configuration

Verifying the Installation and Configuration of PostgreSQL

How to Verify the Installation and Configuration of PostgreSQL

Installing the HA for PostgreSQL Package

How to Install the HA for PostgreSQL Package

Registering and Configuring HA for PostgreSQL

Specifying Configuration Parameters for the PostgreSQL Resource

Specifying the Parameters for the Rolechanger Resource

Specifying Configuration Files for WAL File Shipping Without Shared Storage

Preparing Your PostgreSQL Installation for Cluster Control

How to Prepare Your PostgreSQL for Oracle Solaris Cluster Registration in the Global Zone

How to Prepare Your PostgreSQL for Oracle Solaris Cluster Registration in an HA for Solaris Zones Configuration

Creating and Enabling Resources for PostgreSQL

How to Create and Enable Resources for PostgreSQL

How to Modify Parameters in the HA for PostgreSQL Manifest

How to Remove a HA for PostgreSQL Resource From an HA Container

How to Create and Enable Resources for PostgreSQL Rolechanger

Verifying the HA for PostgreSQL Installation and Configuration

How to Verify the HA for PostgreSQL Installation and Configuration

How to Verify the Oracle Solaris Cluster HA for PostgreSQL WAL File Shipping Installation and Configuration

Tuning the HA for PostgreSQL Fault Monitor

Operation of the HA for PostgreSQL Parameter File

Operation of the Fault Monitor for HA for PostgreSQL

Debugging HA for PostgreSQL

How to Activate Debugging for HA for PostgreSQL

A.  Files for Configuring Oracle Solaris Cluster HA for PostgreSQL Resources

B.  Deployment Example: Installing PostgreSQL in the Global Zone or a Zone Cluster

C.  Deployment Example: Installing PostgreSQL in a Non-Global Zone With HA for Solaris Zones

D.  Deployment Example: Installing PostgreSQL in the Global Zone Using WAL File Shipping

Index

Registering and Configuring HA for PostgreSQL

Before you perform the procedures in this section, ensure that the HA for PostgreSQL data service packages are installed.

The configuration and registration file in the /opt/SUNWscPostgreSQL/util directory exists to register the HA for PostgreSQL resources. This file defines the dependencies that are required between the HA for PostgreSQL component and other resources. For information about these dependencies, see Dependencies Between HA for PostgreSQL Components

This section covers the following main topics:

Specifying Configuration Parameters for the PostgreSQL Resource

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


Note - This configuration file needs to be accessible from the zone where the PostgreSQL software is installed.


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

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

RS=PostgreSQL-resource
RG=PostgreSQL-resource-group
PORT=80
LH=PostgreSQL-logical-hostname-resource-name
HAS_RS=PostgreSQL-has-resource
PFILE=pgsql-parameter-file
ZONE=pgsql-zone
ZONE_BT=pgsql-zone-rs
PROJECT=pgsql-zone-project
USER=pgsql-user
PGROOT=pgsql-root-directory
PGDATA=pgsql-data-directory
PGPORT=pgsql-port
PGHOST=pgsql-host
PGLOGFILE=pgsql-log-file
LD_LIBRARY_PATH=pgsql-ld-library-path
ENVSCRIPT=pgsql-environment-script
SCDB=pgsql-mon-db
SCUSER=pgsql-mon-user
SCTABLE=pgsql-mon-table
SCPASS=pgsql-mon-pwd
NOCONRET=pgsql-noconn-rtcode
STDBY_RS=PostgreSQL-standbyresource
STDBY_RG= PostgreSQL-standby-resource-group
STDBY_USER=PostgreSQL-standby-user
STDBY_HOST=PostgreSQL-standby-host
STDBY_PARFILE=PostgreSQL-standby-parameter-file
STDBY_PING=Number-of packets
ROLECHG_RS=PostgreSQL-rolechanger-resource
SSH_PASSDIR=PostgreSQL-user-passphrase-directory

The meaning and permitted values of the keywords in the pgs_config file are as follows:

RS=PostgreSQL-resource

Specifies the name that you are assigning to the PostgreSQL resource. You must specify a value for this keyword.

RG=PostgreSQL-resource-group

Specifies the name of the resource group where the PostgreSQL resource will reside. 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 PostgreSQL resource. This variable is used only at registration time. If you will not specify an LH, omit this value.

In an HA for Solaris Zonesconfiguration, omit this value.

LH=PostgreSQL-logical-hostname-resource-name

In a global zone configuration, specifies the name of the SUNW.LogicalHostname resource for the PostgreSQL resource. This name must be the SUNW.LogicalHostname resource name you assigned when you created the resource in How to Enable a Non-Global Zone to Run PostgreSQL in an HA for Solaris Zones Configuration. If you did not register a SUNW.LogicalHostname resource, omit this value.

In a configuration using HA for Solaris Zones and WAL file shipping without shared storage, omit this value.

HAS_RS=PostgreSQL-has-resource

Specifies the names of resources on which your PostgreSQL will depend, for example, the SUNW.HAStoragePlus resource, for the PostgreSQL resource. This name must be the SUNW.HAStoragePlus resource name that you assigned when you created the resource in How to Enable a PostgreSQL Database to Run in the Global Zone. Dependencies to additional resources can be specified here. They must be separated by a comma. In a configuration using WAL file shipping without shared storage, omit this value.

PFILE=pgsql-parameter-file

Specifies the name of the parameter file where the PostgreSQL specific parameters of the PostgreSQL resource are stored. This file is automatically created at registration time. You must specify a value for this keyword.

ZONE=pgsql-zonename

Specifies the name of the HA for Solaris Zones configuration to host the PostgreSQL database. Omit this value if you configure a global zone environment.

ZONE_BT=pgsql-zone-rs

Specifies the name of the zone boot resource in an HA for Solaris Zones configuration. Omit this value if you configure a global zone environment.

PROJECT=pgsql-zone-project

Specifies the name of the resource management project in the HA for Solaris Zones. Omitting this value in an HA for Solaris Zones configuration results in the default project for USER. Leave the value blank for a global zone configuration.

USER=pgsql-user

Specifies the name of the Oracle Solaris user who owns the PostgreSQL database. You must specify a value for this keyword.

PGROOT=pgsql-root-directory

Specifies the name of the directory in which PostgreSQL is installed. For example, if PostgreSQL version 8.1.2 is installed in/global/postgres/postgresql-8.1.2, the variable PGROOT needs to be set to /global/postgres/postgresql-8.1.2. A valid PGROOT variable contains the file pg_ctl, which is located in its subdirectory bin. You must specify a value for this keyword.

Examples for PGROOT:

/usr
Root path for PostgreSQL shipped with Oracle Solaris software.
/usr/local/psql
Root path for the PostgreSQL build without a prefix.
/your-path
Fully customized root path for PostgreSQL. This is where to place the binaries on the shared storage. A known convention is /path/postgresql-x.y.z.
PGDATA=pgsql-data-directory

Specifies the name of the directory where the “PostgreSQL data cluster” is initialized. This directory is where the data directories and at least the postgresql.conf file are located. You must specify a value for this keyword.

PGPORT=pgsql-port

Specifies the port on which the PostgreSQL server will listen.

PGHOST=pgsql-host

Specifies the hostname or directory that is used by the probe. If PGHOST is a hostname, the hostname is used by the probe to connect to the database. If PGHOST is a directory, the probe expects the UNIX domain socket in this directory to establish its connection. The PGHOST variable is referenced only by the probe and the database must be configured according to this setting.

PGLOGFILE=pgsql-log-file

Specifies the name of the log file of PostgreSQL. All server messages will be found in this file. You must specify a value for this keyword.

LD_LIBRARY_PATH=pgsql-ld-library-path

Specifies the libraries needed to start the PostgreSQL server and utilities. This parameter is optional.

ENVSCRIPT=pgsql-environment-script

Specifies the name of a script to source PostgreSQL-specific environment variables. In a global zone configuration, the script type is either C shell or Korn shell, according to the login shell of the PostgreSQL user. In an HA for Solaris Zones configuration, the script type must be a valid Korn shell script.

This parameter is optional.

SCDB=pgsql-mon-db

Specifies the name of the PostgreSQL database that will be monitored. You must specify a value for this keyword.

SCUSER=pgsql-mon-user

Specifies the name of the PostgreSQL database user, which is needed to monitor the condition of the database. This user will be created during the installation process. You must specify a value for this keyword.

SCTABLE=pgsql-mon-table

Specifies the name of the table that will be modified to monitor the health of the PostgreSQL application. This table will be created during the installation process. You must specify a value for this keyword.

SCPASS=pgsql-mon-pwd

Specifies the password for SCUSER. If no password is specified, the user set by SCUSER needs to be allowed to log in from the localhost without a password challenge or the stored password must be encrypted.

This parameter is optional.

NOCONRET=pgs-noconn-rtcode

Specifies the value below 100 of the return code for failed database connections. For more information, seeTuning the HA for PostgreSQL Fault Monitor.

STDBY_RS=PostgreSQL-standbyresourse

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

STDBY_RG=PostgreSQL-standby-resourse-group

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

STDBY_USER=PostgreSQL-standby-resourse-user

Specifies the name of the Oracle Solaris user who owns the PostgreSQL standby database. You must specify a value for this keyword on the primary if you configure WAL file shipping as a replacement for shared storage.

STDBY_HOST=PostgreSQL-standby-host

Specifies name of the cluster node that hosts the designated standby database. You must specify a value for this keyword on the primary if you configure WAL file shipping as a replacement for shared storage.

STDBY_PARFILE=PostgreSQL-standby-parameterfile

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

STDBY_PING=Number of packets

Specifies the number of packages the primary uses to ping the standby host. This value is optional and the default is five packets.

ROLECHG_RS=PostgreSQL-rolechanger-resource

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

SSH_PASSDIR=PostgreSQL-user-passphrase-directory

Specifies the directory where a ssh passphrase is stored at registration time. This parameter is optional.

For illustration purposes, two examples for the pgs_config file are provided. The first example shows the pgs_config file for a global zone configuration and second example shows the pgs_config file for an HA for Solaris Zones configuration.

Example 1-1 Sample pgs_config File for a Global Zone Configuration

This example shows a pgs_config file in which configuration parameters are set as follows:

RS=postgres-rs
RG=postgres-rg
PORT=80
LH=postgres-lh
HAS_RS=postgres-has-rs
PFILE=/global/postgres/pfile
ZONE=
ZONE_BT=
PROJECT=
USER=postgres
PGROOT=/global/postgres/postgresql-8.1.2
PGDATA=/global/postgres/data
PGPORT=5432
PGHOST=
PGLOGFILE=/global/postgres/logs/scinstance1
LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/lib:/usr/lib:
ENVSCRIPT=/global/postgres/variables.ksh
SCDB=testdb
SCUSER=testusr
SCTABLE=testtbl
SCPASS=
NOCONRET=10

Example 1-2 Sample pgs_config File for an HA for Solaris Zones Configuration

This example shows an pgs_config file in which configuration parameters are set as follows:

RS=postgres-zrs
RG=postgres-rg
PORT=
LH=
HAS_RS=
PFILE=/postgres/pfile
ZONE=pgs-zone
ZONE_BT=pgs-zone-rs
PROJECT=pgs-project
USER=zpostgr
PGROOT=/postgres/potgresql-8.1.2
PGDATA=/postgres/data
PGPORT=5432
PGHOST=
PGLOGFILE=/postgres/logs/scinstance1
LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/lib:/usr/lib:
ENVSCRIPT=/postgres/variables.ksh
SCDB=testdb
SCUSER=testusr
SCTABLE=testtbl
SCPASS=
NOCONRET=10

Specifying the Parameters for the Rolechanger Resource

Oracle Solaris Cluster HA for PostgreSQL software 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 Rolechanger 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 1-4, the resilvering scripts are also explained in detail.

Example 1-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 1-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

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 ssh key is secured by a passphrase or not.

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

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.

Specifying Configuration Files for WAL File Shipping Without Shared Storage

You need three configuration files:

In addition to these requirements, you also need to customize copies of resilver-step1 and resilver-step2.

The configuration files are as follows:

This example shows a pgs_primary_config file, a pgs_standby_config file, and a rolechg_config file with configuration parameters are set.

The key-value pairs and explanation for a sample pgs_primary_config file are follows:

RS=postgres-prim-rs

The name of the PostgreSQL resource is postgres-prim-rs.

RG=postgres-prim-rg

The name of the resource group for the PostgreSQL resource is postgres-prim-rg.

PORT=80

The value for the dummy port for the PostgreSQL resource is 80.

LH=

SUNW.LogicalHostname resource is not present in postgres-sta-rg.

HAS_RS=

SUNW.HAStoragePlus resource is not present in postgres-sta-rg.

PFILe=/postgres/pfile

The parameter file is generated in /postgres/pfile.

ZONE=

Specifies a global zone configuration.

ZONE_BT=

Specifies a global zone configuration.

PROJECT=

Specifies a global zone configuration.

USER=pgs

The name of the Oracle Solaris user who owns PostgreSQL is pgs.

PGROOT=/postgres/postgresql-8.3.1

The PostgreSQL software is installed in /postgres/postgresql-8.3.1.

PGDATA=/postgres/data

The PostgreSQL data and configuration files are installed under /postgres/data.

PGPORT=5432

The PostgreSQL database server listens on port 5432.

PGLOGFILE=/postgres/logs/scinstance1

The log file for the database server is /postgres/logs/scinstance1.

LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/lib:/usr/lib:

The libraries for the PostgreSQL server are stored in the paths of LD_LIBRARY_PATH/usr/sfw/lib:/usr/local/lib:/usr/lib directory.

ENVSCRIPT=/postgres/variables.ksh

Additional PostgreSQL variables are set in /global/ postgres/variables.ksh.

SCDB=testdb

The monitored database is testdb.

SCUSER=testusr

The user for the database monitoring is testusr.

SCTABLE=testtb1

The table testtb1 is modified to probe the condition of the database.

SCPASS=

The password for the user testusr is testpwd, although it is not specified.

NOCONRET=10

If a connection to the database testdb fails , the probe returns with return code 10.

STDBY_RS=postgres-sta-rs

The resource name of the PostgreSQL standby resource is postgres-sta-rs.

STDBY_RG=postgres-sta-rg

The resource group name of the PostgreSQL standby resource group is postgres-sta-rg.

STDBY_USER=pgs

The user who owns the PostgreSQL standby database is pgs.

STDBY_HOST=phys-node2

The name of the standby host is phys-node2.

STDBY_PARFILE=/postgres/pfile

The parameter file of the PostgreSQL standby resource is /postgres/pfile.

ROLECHG_RS=

The Rolechanger resource name has a null value because it is not needed on the primary.

SSH_PASSDIR=

The SSH_PASSDIR has a null value to indicate that the sshkeys are not protected by a passphrase.

The key-value pairs and explanation for a pgs_standby_config file are as follows:

RS=postgres-sta-rs

The name of the PostgreSQL resource is postgres-sta-rs.

RG=postgres-sta-rg

The name of the resource group for the PostgreSQL resource is postgres-sta-rg.

PORT=80

The value for the dummy port for the PostgreSQL resource is 80.

LH=postgres-sta-rg

SUNW.LogicalHostname resource is not present in postgres-sta-rg.

HAS_RS=

SUNW.HAStoragePlus resource is not present in postgres-sta-rg.

PFILe=/postgres/pfile

The parameter file is generated in /postgres/pfile.

ZONE=

The null value indicates that it is a global zone configuration.

ZONE_BT=

The null value indicates that it is a global zone configuration.

PROJECT=

The null value indicates that it is a global zone configuration.

USER=pgs

The name of the Oracle Solaris user who owns PostgreSQL is pgs.

PGROOT=/postgres/postgresql-8.3.1

The PostgreSQL software is installed in /postgres/postgresql-8.3.1.

PGDATA=/postgres/data

The PostgreSQL data and configuration files are installed under /postgres/data.

PGPORT=5432

The PostgreSQL database server listens on port 5432.

PGLOGFILE=/postgres/logs/scinstance1

The log file for the database server is /postgres/logs/scinstance1.

LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/lib:/usr/lib:

The libraries for the PostgreSQL server are stored in the paths of the LD_LIBRARY_PATH/usr/sfw/lib: /usr/local/lib: /usr/lib: directory.

ENVSCRIPT=/postgres/variables.ksh

Additional PostgreSQL variables are set in /global/postgres/variables.ksh.

SCDB=testdb

The monitored database is testdb.

SCUSER=testusr

The user for the database monitoring is testusr.

SCTABLE=testtb1

The table testtb1 is modified to probe the condition of the database.

SCPASS=

The password for the user testusr is testpwd, although it is not specified.

NOCONRET=10

If a connection to the database testdb fails, the probe returns with return code 10.

STDBY_RS=

The value for the STDBY_RS is not required in a standby configuration.

STDBY_RG=

The value for STDBY_RG is not required in a standby configuration.

STDBY_USER=

The value for STDBY_USER is not required in a standby configuration.

STDBY_HOST=

The value for STDBY_HOST is not required in a standby configuration.

STDBY_PARFILE=

The value for STDBY_PARFILE is not required in a standby configuration.

ROLECHG_RS=rolechg-rs

The Rolechanger resource is rolechg-rs.

SSH_PASSDIR=

The SSH_PASSDIR has a null value , which means that the sshkeys are not protected by a passphrase.

The key-value pairs and explanation for configuration file rolechg-config are as follows:

RS=rolechg-rs

The name of the Rolechanger resource is rolechg-rs.

RG=rolechg-rg

The name of the resource group for the PostgreSQL resource is rolechg-rg.

PORT=5432

The value of the dummy port for the PostgreSQL resource is 5432.

LH=pgs-1h-1

The resource name for the SUNW.LogicalHostname resource is pgs-1h-1.

HAS_RS=

SUNW.HAStoragePlus resource or other dependencies are not present.

STDBY_RS=postgres-sta-rs

The name of the PostgreSQL standby resource is postgres-sta-rs.

PRI_RS=postgres-pri-rs

The name of the PostgreSQL primary resource is postgres-prim-rs.

STDBY_HOST=phys-node

The physical node name of the standby is phys-node2.

STDBY_PFILE=/postgres/pfile

The parameter file on the standby is /postgres/pfile.

TRIGGER=/postgres/data/failover

The trigger file on which the pg_standby utility reacts is phys-node2.

WAIT=30

After the resource is started, Rolechanger waits for 30 seconds until it touches the trigger file.

Modifications in a copy of resilver-step1

SOURCE_DATA=/postgres/data

PGDATA of the standby is in /postgres/data.

TARGET_DATA=/postgres/data

PGDATA of the primary is in /postgres/data.

TARGET=phys-node1

Specifies the name of the target node. The usual name is the name of the designated primary node.

PGS_BASE=/pgs/postgres-8.3

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

PRI_GRP=primary-rg

Specifies the resource group that contains the cluster resource of the designated primary.

STDBY_RS=standby-rs

Specifies the resource group that contains the cluster resource of the designated standby.

PGPORT=5432

Specifies the database port.

ROLECHG_GRP=rolechg-rg

Specifies the resource group that contains the Rolechanger resource.

RSYNC=“/usr/local/bin/rsync –rysnc-path=/usr/local/bin/rysnc —rav”

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

SSH_PASSPHRASE=false

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

Modifications in a copy of resilver-step2

SOURCE=phys-node2

The source node is phys-node2.

SOURCE_DATA=/postgres/data

PGDATA of the standby is in /postgres/data.

TARGET_DATA=/postgres/data

PGDATA of the primary is in /postgres/data.

TARGET=phys-node1

The target node is phys-node1.

PGS_BASE=/user/postgres/8.3

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=postgres-sta-rg

The resource group for the standby resource is postgres-sta-rg.

STDBY_RS=standby-rs

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

PGPORT=5432

Specifies the database port.

ROLECHG_GRP=rolechg-rg

The resource group for the Rolechanger resource group is rolechg-rg.

PRI_NODE=phys-node1

The primary node is the global zone of phys-node1.

RSYNC=“/usr/local/bin/rsync –rysync-path=/usr/local/bin/rsync -rav”

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

SSH_PASSPHRASE=false

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

Preparing Your PostgreSQL Installation for Cluster Control

To prepare your PostgreSQL installation for cluster control, you create a database, a user, and a table to be monitored by the PostgreSQL resource. Because you need to differentiate between a global zone configuration and an HA for Solaris Zones configuration, two procedures are provided.

How to Prepare Your PostgreSQL for Oracle Solaris Cluster Registration in the Global Zone

Before You Begin

Ensure that you have edited the pgs_config file to specify configuration parameters for the HA for PostgreSQL data service. For more information, see Specifying Configuration Parameters for the PostgreSQL Resource.

  1. As superuser change the rights of the configuration file to be accessible for your PostgreSQL user.
    # chmod 755 /myplace/pgs_config
  2. Switch to your PostgreSQL user.
    # su - postgres
  3. If the login shell is not the Korn shell, switch to ksh.
    % ksh
  4. Set the necessary variables.
    $ . /myplace/pgs_config
    $ export PGDATA PGPORT LD_LIBRARY_PATH
  5. If your PostgreSQL is not already running, start the PostgreSQL server.
    $ $PGROOT/bin/pg_ctl -l $PGLOGFILE start
  6. Prepare the database.
    • If you specified the password for the monitoring user in the configuration file or if you do not have a password, do the following:
      $ /opt/SUNWscPostgreSQL/util/pgs_db_prep -f /myplace/pgs_config
    • If you have a password and do not want to specify it in clear text, do the following:
      $ /opt/SUNWscPostgreSQL/util/pgs_db_prep -f /myplace/pgs_config -e
  7. (Optional) Configure your PostgreSQL instance to listen on the logical host's TCP/IP name.

    If you want your PostgreSQL databases to listen on more than localhost, configure the listen_address parameter in the file postgresql.conf. Use a plain text editor such as vi, and set the value of listen_address to an appropriate value.


    Caution

    Caution - The PostgreSQL instance must listen on localhost. For additional information, see http://www.postgresql.org.


    listen_address = 'localhost,myhost'
  8. Set the security policy for the test database.

    Use a plain text editor such as vi to add the following line to the file pg_hba.conf.

    local   testdb         all                               password

    Note - For additional information about the pg_hba.conf file, see http://www.postgresql.org.


  9. Stop the PostgreSQL database server.
    $ $PGROOT/bin/pg_ctl stop

How to Prepare Your PostgreSQL for Oracle Solaris Cluster Registration in an HA for Solaris Zones Configuration

Before You Begin

Ensure, that you have edited the pgs_config file to specify configuration parameters for the HA for PostgreSQL data service. For more information, see Specifying Configuration Parameters for the PostgreSQL Resource. Also make sure that the package directory of the HA for PostgreSQL, /opt/SUNWscPostgreSQL, is available in the target zone.

  1. As superuser change the rights of the configuration file to be accessible for your PostgreSQL user.

    Note - Ensure, that your pgs_config file is accessible from your zone. Otherwise, transfer the file to your zone by using appropriate methods.


    # chmod 755 /myplace/pgs_config
  2. Switch to the target zone.
    # zlogin pgsql-zone
  3. Switch to the PostgreSQL user.
    # su - zpostgr
  4. If the login shell is not the Korn shell, switch to ksh.
    % ksh
  5. Set the necessary variables.
    $ . /myplace/pgs_config
    $ export PGDATA PGPORT LD_LIBRARY_PATH
  6. If your PostgreSQL is not already running, start the PostgreSQL server.
    $ $PGROOT/bin/pg_ctl -l $PGLOGFILE start
  7. Prepare the database.
    • If you specified the password for the monitoring user in the configuration file or if you do not have a password, do the following:
      $ /opt/SUNWscPostgreSQL/util/pgs_db_prep -f /myplace/pgs_config
    • If you have a password and do not want to specify it in clear text, do the following:
      $ /opt/SUNWscPostgreSQL/util/pgs_db_prep -f /myplace/pgs_config -e
  8. (Optional) Configure your PostgreSQL instance to listen on the logical hosts TCP/IP name.

    If you want your PostgreSQL databases to listen on more than localhost, configure the listen_address parameter in the file postgresql.conf. Use a plain text editor such as vi, and set the value of listen_address to an appropriate value.


    Caution

    Caution - The PostgreSQL instance must listen on localhost. For additional information, see http://www.postgresql.org.


    listen_address = 'localhost,myhost'
  9. Set the security policy for the test database.

    Use a plain text editor such as vi to add the following line to the pg_hba.conf file.

    local   testdb         all                               password

    Note - For additional information, see http://www.postgresql.org.


  10. Stop the PostgreSQL database server.
    $ $PGROOT/bin/pg_ctl stop
  11. Leave the target zone and return to the global zone.

Creating and Enabling Resources for PostgreSQL

How to Create and Enable Resources for PostgreSQL

Before You Begin

Ensure that you have edited the pgs_config file to specify configuration parameters for the HA for PostgreSQL data service. For more information, see Specifying Configuration Parameters for the PostgreSQL Resource.

  1. Become superuser on one of the nodes in the cluster that will host PostgreSQL.
  2. Go to the directory that contains the script for creating the HA for PostgreSQL resource.
    # cd /opt/SUNWscPostgreSQL/util
  3. Run the script that creates the PostgreSQL resource.
    • If you specified the password for the monitoring user in the configuration file or if you do not have a password, do the following:
      # ksh ./pgs_register -f /myplace/pgs_config
    • If you have a password and do not want to store it in clear text form, do the following:
      1. Perform the following command on all nodes to run the PostgreSQL resource.
        # ksh ./pgs_register -f /myplace/pgs_config -e
      2. Perform the following command on the node where your shared storage is online.
        # ksh ./pgs_register -f /myplace/pgs_config

    If you omit the -f option, the file /opt/SUNWscPostgreSQL/util/pgs_config is used.

  4. Bring the PostgreSQL resource online.
    # clresource enable postgres-rs

How to Modify Parameters in the HA for PostgreSQL Manifest

Perform this task to change parameters in the HA for PostgreSQL manifest and to validate the parameters in the HA container. Parameters for the HA for PostgreSQL manifest are stored as properties of the SMF service. To modify parameters in the manifest, change the related properties in the SMF service then validate the parameter changes.

  1. Become superuser or assume a role that provides solaris.cluster.modify and solaris.cluster.admin RBAC authorizations on the zones console.
  2. Change the Oracle Solaris Service Management Facilities (SMF) properties for the HA for PostgreSQL manifest.
    # svccfg svc:/application/sczone-agents:resource

    For more information, see the svccfg(1M) man page.

  3. Validate the parameter changes.
    # /opt/SUNWscPostgreSQL/bin/control_pgs validate resource

    Messages for this command are stored in the /var/adm/messages/ directory of the HA container.

  4. Disconnect from the HA for Solaris Zones console.

How to Remove a HA for PostgreSQL Resource From an HA Container

  1. Become superuser or assume a role that provides solaris.cluster.modify and solaris.cluster.admin RBAC authorizations.
  2. Disable and remove the resource that is used by the HA for PostgreSQL data service.
    # clresource disable resource
    # clresource delete resource
  3. Log in as superuser to the HA for Solaris Zones console.
  4. Unregister HA for PostgreSQL from the Oracle Solaris Service Management Facilities (SMF) service.
    # /opt/SUNWscPostgreSQL/util/pgs_smf_remove -f filename
    -f

    Specifies the configuration file name.

    filename

    The name of the configuration file that you used to register HA for PostgreSQL with the SMF service.


    Note - If you no longer have the configuration file that you used to register HA for PostgreSQL with the SMF service, create a replacement configuration file:

    1. Make a copy of the default file, /opt/SUNWscPostgreSQL/util/pgs_config.

    2. Set the ZONE and RS parameters with the values that are used by the data service.

    3. Run the pgs_smf_remove command and use the -f option to specify this configuration file.


  5. Disconnect from the HA for Solaris Zones console.

How to Create and Enable Resources for PostgreSQL Rolechanger

Before You Begin

Ensure that you have edited the rolechg_config file to specify configuration parameters for the HA for PostgreSQL Rolechanger data service. For more information, see http://www.postgresql.org.

  1. Become superuser on one of the nodes in the cluster that hosts PostgreSQL.
  2. Go to the directory that contains the script for creating the HA for PostgreSQL Rolechanger resource.
    # cd /opt/SUNWscPostgreSQL/util
  3. Run the script that creates the PostgreSQL resource.
    # ksh ./rolechg_register -f /myplace/rolechg_config

    If you omit the -f option, the file /opt/SUNWscPostgreSQL/rolechg_util/rolechg_config is used.

  4. Bring the PostgreSQL Rolechanger resource online.
    # clresource enable rolechg-rs