This appendix presents a complete example of how to install and configure the PostgreSQL application and data service in the global zone. It presents a simple two-node cluster configuration. If you need to install the application in any other configuration, refer to the general-purpose procedures presented elsewhere in this manual. For an example of PostgreSQL installation in a non-global zone, see Appendix D, Deployment Example: Installing PostgreSQL in a Non-Global Zone, for a non global zone, see Appendix C, Deployment Example: Installing PostgreSQL in a Non-Global Failover Zone.
This example uses a two-node cluster with the following node names:
phys-schost-1 (a physical node, which owns the file system)
phys-schost-2 (a physical node)
This configuration also uses the logical host name ha-host-1.
This deployment example uses the following software products and versions:
Solaris 10 6/06 software for SPARC or x86 platforms
Sun Cluster 3.2 core software
Sun Cluster Data Service for PostgreSQL
PostgreSQL version 8.1.0 source files
readline
gmake
Your preferred text editor
Your preferred C compiler
This example assumes that you have already installed and established your cluster. It illustrates installation and configuration of the data service application only.
The steps for installing PostgreSQL in a cluster that runs on Solaris version 9 OS are identical to the steps in this example.
The instructions in this example were developed with the following assumptions:
Shell environment: All commands and the environment setup in this example are for the Korn shell environment. If you use a different shell, replace any Korn shell-specific information or instructions with the appropriate information for you preferred shell environment.
User login: Unless otherwise specified, perform all procedures as superuser or assume a role that provides solaris.cluster.admin, solaris.cluster.modify, and solaris.cluster.read RBAC authorization.
The tasks you must perform to install and configure PostgreSQL in the global zone are as follows:
Example: Building and Installing the PostgreSQL Software on Shared Storage
Example: Enabling the PostgreSQL Software to Run in the Cluster
Install and configure the cluster as instructed in Sun Cluster Software Installation Guide for Solaris OS.
Install the following cluster software components on both nodes.
Sun Cluster core software
Sun Cluster data service for PostgreSQL
Install the following utility software on both nodes:
readline
gmake
Your C compiler
Beginning on the node that owns the file system, add the postgres user.
phys-schost-1# groupadd -g 1000 postgres phys-schost-2# groupadd -g 1000 postgres phys-schost-1# useradd -g 1000 -d /global/mnt3/postgres -m -s /bin/ksh postgres phys-schost-2# useradd -g 1000 -d /global/mnt3/postgres -m -s /bin/ksh postgres |
Register the necessary data types on both nodes.
phys-schost-1# clresourcetype register SUNW.gds SUNW.HAStoragePlus |
Create the PostgreSQL resource group.
phys-schost-1# clresourcegroup create RP-PGS |
Create the logical host.
phys-schost-1# clreslogicalhostname create -g RG-PGS ha-host-1 |
Create the HAStoragePlus resource in the RG-PGS resource group.
phys-schost-1# clresource create -g RG-PGS -t SUNW.HAStoragePlus -p AffinityOn=TRUE \ -p FilesystemMountPoints=/global/mnt3,/global/mnt4 RS-PGS-HAS |
Enable the resource group.
phys-schost-1# clresourcegroup online -M RG-PGS |
Modify the PGROOT and PD_LIBRARY_PATH environment variables according to the needs of your build.
The databases are stored under /global/mnt3/postgres/data.
The log is stored under /global/mnt3/postgres/logs/sclog.
phys-schost-1# PGROOT=/global/mnt3/postgres/postresql-8.1.0 phys-schost-1# LD_LIBRARY_PATH=/global/mnt3/postgres/postgresql-8.1.0:/usr/sfw/lib:\ /usr/local/lib:/usr/lib:/opt/csw/lib phys-schost-1# export PGROOT phys-schost-1# export LD_LIBRARY_PATH |
If you are installing the software in the default directory, set PGROOT to /usr/local/pgsql and LD_LIBRARY_PATH to /usr/local/pgsql/lib:/usr/sfw/lib:/usr/local/lib:/usr/lib:/opt/csw/lib.
Copy the PostgreSQL configuration file from the agent directory to its deployment location.
phys-schost-1# cp /opt/SUNWscPostgreSQL/util/pgs_config /global/mnt3 |
Add this cluster's information to the configuration file.
The following listing shows the relevant file entries and the values to assign to each entry.
. . . RS=RS-PGS RG=RG-PGS PORT=5432 LH=hahostix1 HAS_RS=RS-PGS-HAS PFILE=/global/mnt3/postgres/RS-PGS-pfile . . . USER=postgres PGROOT=/usr/local/pgsql #PGROOT=/global/mnt3/postgres/postgresql-8.1.0 PGDATA=/global/mnt3/postgres/data PGPORT=5432 PGLOGFILE=/global/mnt3/postgres/logs/sclog LD_LIBRARY_PATH=/usr/local/pgsql/lib:/usr/sfw/lib:/usr/local/lib:/usr/lib:/opt/csw/lib #LD_LIBRARY_PATH=/global/mnt3/postgres/postgresql-8.1.0/lib:/usr/sfw/lib #LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/lib:/opt/csw/lib |
Save and close the file.
These steps illustrate how to install the PostgreSQL software on shared storage. You can also build and install the PostgreSQL binaries in the default directory /usr/local/pgsql. See <xref an place we figure out to put the alternative approach, unless we don't figure it out>.
Log in as the PostgreSQL user.
phys-schost-1# su - postgres |
Set up the build environment.
Install the source and configure the build.
phys-schost-1$ gzcat /tmp/postgresql-8.1.0.tag.gz | tar xvf - phys-schost-1$ cd /global/mnt3/postgres/build/postgresql-8.1.0 phys-schost-1$ ./configure --prefix=/global/mnt3/postgres/postgresql-8.1.0 |
Build the PostgreSQL binaries.
phys-schost-1$ gmake |
If you use gcc to build the postgres binaries, build them in a failover file system.
Run the PostgreSQL regression tests.
phys-schost-1$ gmake check |
Install the PostgreSQL binaries.
phys-schost-1# gmake install |
Clean the distribution.
phys-schost-1$ gmake clean |
Create the directories for the databases and the log file.
phys-schost-1$ mkdir /global/mnt3/postgres/data phys-schost-1$ mkdir /global/mnt3/postgres/logs |
Change to the PostgreSQL root directory and initialize the data cluster.
phys-schost-1$ cd /global/mnt3/postgres/postgresql-8.1.0 phys-schost-1$ ./bin/initdb -D /global/mnt3/postgres/data |
Start the database.
phys-schost-1$ ./bin/postmaster -D /global/mnt3/postgresql-8.1.0 |
Prepare the Sun Cluster specific test database.
phys-schost-1$ ksh /opt/SUNWscPostgreSQL/util/pgs_db_prep -f /global/mnt3/pgs_config |
Stop the postmaster.
phys-schost-1$ ./bin/pg_ctl -D /global/mnt3/data stop |
Exit the postgres user ID.
phys-schost-1$ exit |
Run the pgs_register script to register the resource.
phys-schost-1# ksh /opt/SUNWscPostgreSQL/util/pgs-register -f /global/mnt3/pgc_config |
Add the following line to the postgresql.conf file in the PGDATA directory.
listen_addresses = 'localhost,ha-host-1' |
Add the following line to the pg_hba.conf file in the PGDATA directory.
host all all 0.0.0.0/0 password |
Enable the resource.
phys-schost-1# clresource enable RS-PGS |
The instructions in Installing and Configuring PostgreSQL on Shared Storage in the Global Zone install the PostgreSQL software on shared cluster storage. You can also install this software in the default directory /usr/local/pgsql.
To install the PostgreSQL software in the default directory, perform the steps provided in the following example procedures:
LExample: Building and Installing the PostgreSQL Software in the Default Directory in the Global Zone
Example: Enabling the PostgreSQL Software to Run in the Cluster
These steps illustrate how to install the PostgreSQL software in the default directory /usr/local/pgsql. You can also build and install the PostgreSQL binaries on shared storage. See Installing and Configuring PostgreSQL on Shared Storage in the Global Zone.
Log in as the PostgreSQL user.
phys-schost-1# su - postgres |
Expand the software tar file.
phys-schost-1$ gzcat /tmp/postgresql-8.1.0.tar.gz |tar xvf - |
Add the C compiler and ar to your PATH.
phys-schost-1$ PATH=$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin phys-schost-1$ export PATH |
Add the C compiler and readline libraries to your LD_LIBRARY_PATH.
phys-schost-1$ LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/lib:/usr/lib:/opt/csw/lib phys-schost-1$ export LD_LIBRARY_PATH |
Install the source and configure the build.
phys-schost-1$ gzcat /tmp/postgresql-8.1.0.tar.gz |tar xvf - phys-schost-1$ cd /global/mnt3/postgres/build/postgresql-8.1.0 phys-schost-1$ ./configure |
Build the PostgreSQL binaries.
phys-schost-1$ gmake |
If you use gcc to build the postgres binaries, build them in a failover file system.
Run the PostgreSQL regression tests.
phys-schost-1$ gmake check |
Log back in as root.
phys-schost-1$ su |
Add the C compiler and ar to your PATH.
This example assumes the following:
The compiler is gcc, located in /usr/sfw/bin.
ar is located in /usr/ccs/bin.
phys-schost-1# PATH=$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin phys-schost-1# export PATH |
Add the C compiler and readline libraries to your LD_LIBRARY_PATH.
phys-schost-1# LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/lib:/usr/lib:/opt/csw/lib phys-schost-1# export LD_LIBRARY_PATH |
Install the binaries.
phys-schost-1# gmake install |
Copy the binaries to the second node.
phys-schost-1# scp -rp /usr/local/pgsql phys-schost-2:/usr/local |
Exit from root access.
phys-schost-1# exit |
Clean the distribution.
phys-schost-1% gmake clean |
Perform the steps in Example: Enabling the PostgreSQL Software to Run in the Cluster to complete installation and configuration of PostgreSQL.