These instructions assume that you are installing the PostgreSQL software as the postgres user in a shared directory. For instructions on installing the software in the default directory /usr/local/pgsql, see XREFtheOtherOneInstalling the PostgreSQL Binaries in the Default Directory in an HA Container (Alternative Installation).
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 in an HA Container
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
Sun Cluster data service for Solaris containers
Install the following utility software on both nodes:
readline
gmake
Your C compiler
This example is based upon “How to Enable a Zone to Run in a Failover Configuration” in the Sun Cluster Data Service for Solaris Containers Guide.
Register the HAStoragePlus resource type.
phys-schost-1# clresourcetype register SUNW.gds SUNW.HAStoragePlus |
Create the PostgreSQL resource group.
phys-schost-1# clresourcegroup create RP-PGS |
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-PSG |
On shared cluster storage, create a directory for the HA container root path.
This example presents a sparse root zone. You can use a whole root zone if that type better suits your configuration.
phys-schost-1# mkdir /global/mnt3/zones |
Create a temporary file, for example /tmp/x, and include the following entries:
create -b set zonepath=/global/mnt3/zones/clu1 set autoboot=false set pool=pool_default add inherit-pkg-dir set dir=/lib end add inherit-pkg-dir set dir=/platform end add inherit-pkg-dir set dir=/sbin end add inherit-pkg-dir set dir=/usr end add net set address=hahostix1 set physical=hme0 end add attr set name=comment set type=string set value="PostgreSQL cluster zone" Put your desired zone name between the quotes here. end |
Configure the HA container, using the file you created.
phys-schost-1# zonecfg -z clu1 -f /tmp/x |
Install the zone.
phys-schost-1# zoneadm -z clu1 install |
Log in to the zone.
phys-schost-1# zlogin -C clu1 |
Open a new window to the same node and boot the zone?
phys-schost-1a# zoneadm -z clu1 boot |
Close this terminal window and disconnect from the zone console.
phys-schost-1# ~~. |
Copy the containers configuration file to a temporary location.
phys-schost-1# cp /opt/SUNWsczone/sczbt/util/sczbt_config /tmp/sczbt_config |
Edit the /tmp/sczbt_config file and set variable values as shown:
RS=RS-PGS-ZONE RG=RG-PGS PARAMETERDIR=/global/mnt3/zonepar SC_NETWORK=false SC_LH= FAILOVER=true HAS_RS=RS-PGS-HAS Zonename=clu1 Zonebootopt= Milestone=multi-user-server Mounts= |
Create the zone according to the instructions in the Sun Cluster Data Service for Solaris Containers Guide.
Register the zone resource.
phys-schost-1# ksh /opt/SUNWsczone/sczbt/util/sczbt_register -f /tmp/sczbt_config |
Enable the zone resource.
phys-schost-1# clresource enable RS-PGS-ZONE |
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# PG_ROOT=/global/mnt3/postgres/postgresql-8.1.0 phys-schost-1# LD_LIBRARY_PATH=/global/mnt3/postgres/postgresql-8.1.0/lib \ phys-schost-1# LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/sfw/lib:/usr/local/lib: \ /usr/lib:/opt/csw.lib phys-schost-1# export LD_LIBRARY_PATH PG_ROOT |
Store the pfile in a directory in the zone clu1.
The configuration file name must be available in the zone.
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 . . . # local zone specific options ZONE=clu1 ZONE_BT=RS-PGS-ZONE ZUSER=postgres PROJECT= . . . USER=postgres PGROOT=/usr/local/pgsql #PGROOT=/global/mnt3/postgres/postgresql-8.1.0 PGDATA=/global/mnt3/postgres/data PGPORT=5432 PGHOST= 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=/usr/sfw/lib:/usr/local/lib:/usr/lib:/opt/csw/lib #LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/sfw/lib:/usr/local/lib:/usr/lib:/opt/csw/lib ENVSCRIPT= SCDB=sctest SCUSER=scuser SCTABLE=sctable SCPASS=scuser |
Save and close the file.
Transfer this configuration file in the zone clu1 under /tmp/pgs_config.
phys-schost-1# scp /global/mnt3/pgs_config clu1:/tmp |
This example illustrates 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 Installing the PostgreSQL Binaries in the Default Directory in an HA Container (Alternative Installation).
Log in to the zone.
phys-schost-1# zlogin clu1 |
Add the postgres user.
zone# groupadd -g 1000 postgres zone# useradd -g 1000 -u 1006 -d /postgres -m -s /bin/ksh postgres |
Log in as the PostgreSQL user.
zone# su - postgres |
Set up the build environment.
Install the source and configure the build.
zone$ gzcat /tmp/postgresql-8.1.0.tag.gz | tar xvf - zone$ cd /global/mnt3/postgres/build/postgresql-8.1.0 zone$ ./configure --prefix=/global/mnt3/postgres/postgresql-8.1.0 |
Build the PostgreSQL binaries.
zone$ gmake |
If you use gcc to build the postgres binaries, build them in a failover file system.
Run the PostgreSQL regression tests.
zone$ gmake check |
Install the PostgreSQL binaries.
zone$ gmake install |
Clean the distribution.
zone$ gmake clean |
Create the directories for the databases and the log file.
zone$ mkdir /global/mnt3/postgres/data zone$ mkdir /global/mnt3/postgres/logs |
Change to the PostgreSQL root directory and initialize the data cluster.
zone$ cd /postgres/postgresql-8.1.0 zone$ ./bin/initdb -D postgres/data |
Start the database.
zone$ ./bin/postmaster -D /postgresql-8.1.0 |
Prepare the Sun Cluster specific test database.
zone$ ksh /opt/SUNWscPostgreSQL/util/pgs_db_prep -f /tmp/pgs_config |
Stop the postmaster.
zone$ ./bin/pg_ctl -D /postgres/data stop |
Add the following line to the /postgres/data/postgresql.conf file.
listen_addresses = 'localhost,ha-host-1' |
Add the following line to the /postgres/data/pg_hba.conf file.
host all all 0.0.0.0/0 password |
Leave the zone.
zone$ exit |
Run the pgs_register script to register the resource.
phys-schost-1# ksh /opt/SUNWscPostgreSQL/util/pgs_register -f /global/mnt3/pgs_config |
Enable the resource.
phys-schost-1# clresource enable RS-PGS |