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 |