Sun Cluster Data Service for PostgreSQL Guide for Solaris OS

Installing and Configuring PostgreSQL

This section explains only the special requirements for installing PostgreSQL for use with Sun Cluster HA for PostgreSQL. For complete information about installing and configuring PostgreSQL, see http://www.postgresql.org. For complete information about installing and configuring a Solaris Container, see System Administration Guide: Solaris Containers-Resource Management and Solaris Zones.

Determine if the sun supplied PostgreSQL is already installed and if the installed version will fulfill your requirements. To do this you need to check if at least the three following packages are installed on your system.

SUNWpostgr

SUNWpostgr-libs

SUNWpostgr-server-data

To determine which PostgreSQL version is installed, submit the following commands.


# su - non-root-user
$ postmaster --version

If they are not installed, you need to decide wether you wan to install PostgreSQL from the Solaris Media or if you want to build PostgreSQL on your own. If the version does not fulfill your needs, you have to build PostgreSQL on your own.

For each PostgreSQL database that you are installing and configuring choose the following tasks according to your zone type.

Determine whether you have to configure Sun Cluster HA for PostgreSQL to run in a global zone, in a zone or in a failover zone configuration. The global zone configuration procedure is applicable if you install PostgreSQL on Solaris 9, or in the global zone of Solaris 10. The failover zone configuration procedure is applicable if you install PostgreSQL in a failover zone.

To install and configure PostgreSQL in a global zone configuration, complete the following tasks:

To install and configure PostgreSQL in a zone configuration, complete the following tasks:

To install and configure PostgreSQL in a failover zone configuration, complete the following tasks:

ProcedureHow to Enable a PostgreSQL Database to Run in a Global Zone Configuration

For a complete example of deploying in a global zone, see Appendix B, Deployment Example: Installing PostgreSQL in the Global Zone.

  1. As superuser register the SUNW.HAStoragePlus and the SUNW.gds resource types.


    # clresourcetype register SUNW.HAStoragePlus SUNW.gds
    
  2. Create a failover resource group.


    # clresourcegroup create PostgreSQL-resource-group
    
  3. Create a resource for the PostgreSQL`s disk storage.


    # clresource create -t SUNW.HAStoragePlus \
    -p FileSystemMountPoints=PostgreSQL-instance-mount-points \
    PostgreSQL-has-resource
    
  4. (Optional) If you plan to access the database from a logical host, choose the following tasks according to your zone type.


    # clreslogicalhostname create -g PostgreSQL-resource-group \
    PostgreSQL-logical-hostname-resource-name
    
  5. Enable the failover resource group.


    # clresourcegroup online -M PostgreSQL-resource-group
    
  6. Create a directory for the Sun Cluster HA for PostgreSQL parameter file.


    # mkdir  PostgreSQL-instance-mount-points/parameter-dir
    

Procedure How to Install and Configure PostgreSQL in a Global Zone


Note –

For complete information about installing PostgreSQL, go to http://www.postgresql.org.


For a complete example of deployment in a global zone, see Appendix B, Deployment Example: Installing PostgreSQL in the Global Zone.

Before You Begin

Determine the following requirements for the deployment of PostgreSQL with Sun Cluster:

The following assumptions are made:

  1. As superuser create the home directory for the PostgreSQL user on one node.


    # mkdir /global/postgres
    
  2. Add a group for PostgreSQL on every node.


    # groupadd -g 1000 postgres
    
  3. Add a user who owns the PostgreSQL installation on every node.


    # useradd -u 1000 -g postgres -d /global/postgres -s /usr/bin/ksh postgres
    # chown -R postgres:postgres /global/postgres
    
  4. Switch to the PostgreSQL user.


    # su - postgres
    
  5. Set your PATH variable.


    $ PATH=$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin
    $ export PATH
    
  6. Set your LD_LIBRARY_PATH variable.


    $ LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/lib:/usr/lib:
    $ export LD_LIBRARY_PATH
    
  7. Switch to your build directory.


    $ cd /tmp/postgres/version
    
  8. Configure the PostgreSQL build.


    $ ./configure --prefix=/global/postgres/version
    
  9. Complete, verify and install the build.


    $ gmake
    $ gmake check
    $ gmake install
    

ProcedureHow to Enable a Zone to Run PostgreSQL in a Zone Configuration

For a complete example of deploying in a zone, see Appendix D, Deployment Example: Installing PostgreSQL in a Non-Global Zone.

  1. As superuser register the SUNW.HAStoragePlus and the SUNW.gds resource types.


    # clresourcetype register SUNW.HAStoragePlus SUNW.gds
    
  2. Install and boot the zone pgs-zone on all the nodes to host Sun Cluster HA for PostgreSQL.

  3. Create a failover resource group.


    # clresourcegroup create -n node-1:pgs-zone,node-2:pgs-zone PostgreSQL-resource-group
    
  4. Create a resource for the PostgreSQL zone`s disk storage.


    # clresource create -t SUNW.HAStoragePlus \
    -p FileSystemMountPoints=PostgreSQL-instance-mount-points \
    PostgreSQL-has-resource
    
  5. (Optional) Create a resource for the PostgreSQL`s logical hostname.


    # clreslogicalhostname create -g PostgreSQL-resource-group \
    PostgreSQL-logical-hostname-resource-name
    
  6. Enable the resource group.


    # clresourcegroup online -M  PostgreSQL-resource-group
    

Procedure How to Install and Configure PostgreSQL in a Zone


Note –

For complete information about installing PostgreSQL, go to http://www.postgresql.org.


For a complete example of deploying in a failover zone, see Appendix D, Deployment Example: Installing PostgreSQL in a Non-Global Zone.

Before You Begin

Determine the following requirements for the deployment of PostgreSQL with Sun Cluster:

The following assumptions are made:

  1. As superuser log in to the zone.


    # zlogin postgres-zone
    
  2. Add a group for PostgreSQL.


    # groupadd -g 1000 postgres
    
  3. Add a user who owns the PostgreSQL installation on every node.


    # useradd -u 1000 -g postgres -d /postgres -m -s /usr/bin/ksh postgres
    
  4. Switch to the PostgreSQL user.


    # su - postgres
    
  5. Set your PATH variable.


    $ PATH=$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin
    $ export PATH
    
  6. Set your LD_LIBRARY_PATH variable.


    $ LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/lib:/usr/lib:
    $ export LD_LIBRARY_PATH
    
  7. Switch to your build directory.


    $ cd /tmp/postgres/version
    
  8. Configure the PostgreSQL build.


    $ ./configure --prefix=/postgres/version
    
  9. Complete, verify, and install the build.


    $ gmake
    $ gmake check
    $ gmake install
    

ProcedureHow to Enable a Zone to Run PostgreSQL in a Failover Zone Configuration

For a complete example of deploying in a failover zone, see Appendix D, Deployment Example: Installing PostgreSQL in a Non-Global Zone.

  1. As superuser register the SUNW.HAStoragePlus and the SUNW.gds resource types.


    # clresourcetype register SUNW.HAStoragePlus SUNW.gds
    
  2. Create a failover resource group.


    # clresourcegroup create PostgreSQL-resource-group
    
  3. Create a resource for the PostgreSQL zone`s disk storage.


    # clresource create -t SUNW.HAStoragePlus \
    -p FileSystemMountPoints=PostgreSQL-instance-mount-points \
    PostgreSQL-has-resource
    
  4. (Optional) If you want the protection against a total adapter failure for your public network, create a resource for the PostgreSQL`s logical hostname.


    # clreslogicalhostname create -g PostgreSQL-resource-group \
    PostgreSQL-logical-hostname-resource-name
    
  5. Place the resource group in the managed state.


    # clresourcegroup online -M  PostgreSQL-resource-group
    
  6. Install the zone.

    Install the zone according to the Sun Cluster HA for Solaris Containers agent documentation, assuming that the resource name is pgsql-zone-rs and that the zone name is pgsql-zone.

  7. Verify the zone's installation.


    # zoneadm -z pgsql-zone boot
    # zoneadm -z pgsql-zone halt
    
  8. Register the zone's boot component.

    1. Copy the container resource boot component configuration file.


      # cp /opt/SUNWsczone/sczbt/util/sczbt_config zones-target-configuration-file
      
    2. Use a plain text editor to set the following variables:

      RS=pgsql-zone-rs
      RG=PostgreSQL-resource-group
      PARAMETERDIR=pgsql-zone-parameter-directory
      SC_NETWORK=true|false
      SC_LH=PostgreSQL-logical-hostname-resource-name
      FAILOVER=true|false
      HAS_RS=PostgreSQL-has-resource
      Zonename=pgsql-zone
      Zonebootopt=zone-boot-options
      Milestone=zone-boot-milestone
      Mounts=
    3. Create the parameter directory for your zone's resource.


      # mkdir pgsql-zone-parameter-directory
      
    4. Execute the Sun Cluster HA for Solaris Container's registration script.


      # /opt/SUNWsczone/sczbt/util/sczbt_register -f zones-target-configuration-file
      
    5. Enable the Solaris Container resource


      # clresource enable pgsql-zone-rs
      
  9. Enable the resource group.


    # clresourcegroup online PostgreSQL-resource-group
    

Procedure How to Install and Configure PostgreSQL in a Failover Zone


Note –

For complete information about installing PostgreSQL, go to http://www.postgresql.org.


For a complete example of deploying in a failover zone, see Appendix D, Deployment Example: Installing PostgreSQL in a Non-Global Zone.

Before You Begin

Determine the following requirements for the deployment of PostgreSQL with Sun Cluster:

The following assumptions are made:

  1. Log in to the zone.


    # zlogin postgres-zone
    
  2. Add a group for PostgreSQL.


    # groupadd -g 1000 postgres
    
  3. Add a user who owns the PostgreSQL installation on every node.


    # useradd -u 1000 -g postgres -d /postgres -m -s /usr/bin/ksh postgres
    
  4. Switch to the PostgreSQL user.


    # su - postgres
    
  5. Set your PATH variable.


    $ PATH=$PATH:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin
    $ export PATH
    
  6. Set your LD_LIBRARY_PATH variable.


    $ LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/lib:/usr/lib:
    $ export LD_LIBRARY_PATH
    
  7. Switch to your build directory.


    $ cd /tmp/postgres/version
    
  8. Configure the PostgreSQL build.


    $ ./configure --prefix=/postgres/version
    
  9. Complete, verify, and install the build.


    $ gmake
    $ gmake check
    $ gmake install