Assumptions: 2 zones on a single node cluster or two nodes in a two node cluster. This example is to replicate between two zones in a single node cluster. Assumtions; 1. The physical node is named node1 2. zonea the designated primary 3. zoneb the designated standby 4. The postgres user will be pgs 5. The PGDATA will be /pgs/data 6. Rsync is available in /usr/local/bin/rsync 7. A pg_standby is available under /usr/postgres/8.2/bin 8. The logical host is pgslh-1 and has this name as an alias in the global zones /etc/hosts. System preparation ################## 1 configure zonea and zoneb 2 Add a user pgs and a group pgsdba in each zone 3 log in to each zone as the pgs user and create public ssh keys $ ssh-keygen -t dsa 4 copy the public keys from zonea to zoneb and vice versa 5 copy the public key from the remote zone to ./ssh/authorized_keys2 6 test the trust from each zone with ssh ls 7 On each zone create the following directories. /pgs /pgs/conf /pgs/logs /pgs/scripts /pgs/82_walarchives Be sure that the whole tree belongs to the user pgs Preparartion of the Postgres agent configuration files ###################################################### create the following 3 files as root in the global zone probaly in the directory /config-files: primary.cfg for the designated primary resource standby.cfg for the designated standby resource rolechg.cfg for the designated standby resource The method is either to copy /opt/SUNWscPostgreSQL/util/pgs_config to primary.cfg and standby.cfg and opt/SUNWscPostgreSQL/rolechg/util/rolechg_config. Fill in the necessary variables, or take the cats from the appendix. Preparation of the postgres database #################################### On the primary Login in to zonea as pgs Initialze the database eg /usr/postgres/8.2/bin/initdb -D /pgs/data . Create the minimal configuration files in /pgs/conf. mv /pgs/data/postgresql.conf /pgs/conf ln -s /pgs/conf/postgresql.conf /pgs/data/postgresql.conf Configure the archive command in /pgs/conf/postgresql.conf with the following content: archive_command = '/usr/local/bin/rsync -arv %p zoneb:/pgs/82_walarchives/%f -sshpass. # This parameter is needed only if you configured WAL file shipping and secured your # ssh key with a passphrase. # Leave it undefined if the passprase is empty. # # If you configure the logfile shipping in a shared nothing topology, do not set the LH parameter. # # configure the following paramters on the primary host STDBY_RS=des-sta-rs STDBY_RG=des-sta-rg STDBY_USER=pgs STDBY_HOST=zoneb STDBY_PARFILE=/pgs/pfile-pgs-standby-rs # # configure the following paramters on the standby host # ROLECHG_RS= # # Configure the following parameter on both hosts. # SSH_PASSDIR= ########################################################################################################### standby.cfg deulwork20:/config-files/robert # cat standby.cfg # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" # # This file will be sourced in by pgs_register and the parameters # listed below will be used. # # These parameters can be customized in (key=value) form # # RS - name of the resource for the application. # RG - name of the resource group containing RS. # PORT - name of the port number. # LH - name of the LogicalHostname SC resource. # Do not set the LH variable if you plan to have a network # unaware installation. # HAS_RS - Name of the HAStoragePlus SC resource. # PFILE - Parameter file which contains the PostgreSQL specific # parameters, this file will be created by the register script. # # The following variables need to be set only if the agent runs in a # failover zone # # ZONE - Zonename where the zsmf component should be registered # ZONE_BT - Resource name of the zone boot component # PROJECT - A project in the zone, that will be used for the PostgreSQL # smf service. # PROJECT - A project in the zone, that will be used for the PostgreSQL # smf service. # If the variable is not set it will be translated as :default for # the smf credentialss. # Optional # RS=des-sta-rs RG=des-sta-rg PORT=5432 LH= HAS_RS= PFILE=/pgs/pfile-pgs-standby-rs # failover zone specific options ZONE= ZONE_BT= PROJECT= # # Content for the parameter file # # USER - The Solaris user who owns the PostgreSQL database. # PGROOT - Contains the path to the PostgreSQL directory. Below this # directory the postgres binaries are located in the ./bin # directory. # PGDATA - Contains the path to the databases of this specific PostgreSQL # instance. # PGPORT - Port where the postmaster process will be listening to. # PGHOST - Hostname where the postmaster process is listening to, or a directory where the # Unix socket file is stored. # If set to a valid hostname, the PGHOST variable forces the probe to # traverse the TCP/IP stack. If the PGHOST variable is empty or starts with a "/", # the probe will use a socket. If the PGHOST variable starts with a "/", the entry must # be the directory which contains the socket file. # PGLOGFILE - Logfile where the log messages of the postmaster will be stored. # LD_LIBRARY_PATH - This path contains all the necessary libraries for this PostgreSQL # installation. # Optional # ENVSCRIPT - Script to contain PostgreSQL specific runtime variables. # Optional # SCDB - This database will be monitored. # SCUSER - PostgresSQL user to connect to the $SCDB database. # SCTABLE - Table name in the $SCDB database. This table name will be manipulated # to check if PostgreSQL is alive. This table will be generated at database # preparation time. # SCPASS - Password of the SCUSER # Optional # NOCONRET - Return code for connection errors. This return code has to follow the rules # for the generic data service. The value has to be between 1 and 100. # 100/NOCONRET defines the number of consecutive probes to ignore for failed # connections. A restart or failover will occur, if the number is exeeded within # the retry interval. USER=pgs PGROOT=/usr/postgres/8.2/ PGDATA=/pgs/data PGPORT=5432 PGLOGFILE=/pgs/logs/sc2 LD_LIBRARY_PATH= ENVSCRIPT= SCDB=sctest SCUSER=scuser SCTABLE=sctsttbl SCPASS= NOCONRET=10 # The following parameters need to be configured only if logfile shipping is configured to ship # the PosgreSQL WAL logs between a designated primary and a designated standby resource. # They need to be configured only on the primary. # STDBY_RS The resource name of the PostgreSQL standby resource. # STDBY_RG The resource group name of the PostgreSQL standby resource group. # STDBY_USER User which is the owner of the standby postgres database. # STDBY_HOST Nodename of the standby host or the standby zone. # STDBY_PARFILE The standbys postgres parameter file to get the rest necessary parameters. # ROLECHG_RS The rolechangers resource name. # SSH_PASSDIR A directory where the ssh passphrase is stored in a the file -sshpass. # This parameter is needed only if you configured WAL file shipping and secured your # ssh key with a passphrase. # Leave it undefined if the passprase is empty. # # If you configure the logfile shipping in a shared nothing topology, do not set the LH parameter. # # configure the fillowing paramters on the primary host STDBY_RS= STDBY_RG= STDBY_USER= STDBY_HOST= STDBY_PARFILE= # # configure the following paramters on the standby host # ROLECHG_RS=rolechg-rs # # Configure the following parameter on both hosts. # SSH_PASSDIR= ########################################################################################################### rolechg.cfg deulwork20:/config-files/robert # cat rolechg.cfg # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "@(#)rolechg_config.ksh 1.1 07/11/06 SMI" # # This file will be sourced in by rolechg_register and the parameters # listed below will be used. # # These parameters can be customized in (key=value) form # # RS - name of the resource for the application. # RG - name of the resource group containing RS. # PORT - name of the port number. # LH - name of the LogicalHostname SC resource. # Do not set the LH variable if you plan to have a network # unaware installation. # HAS_RS - Name of the HAStoragePlus SC resource. # STDBY_RS - The resource name of designated standby database # PRI_RS - The resource name of designated primary database # SDBY_HOST - Hostname or zonename of the standby host. If empty, a role switch # will be initiated on any host. # SDBY_PFILE - Parameter file which contains the PostgreSQL specific # parametersfor the standby database. This file is mentined in # the Start_command of the PostgreSQL standby resource. # the Start_command of the PostgreSQL standby resource. # TRIGGER - The filename which will get created in the PGDATA directory. # this filename is mentioned in the recovery.conf file of the # PostgreSQL standby database. # WAIT - A number of seconds the start method waits before it touches # the trigger file. If the trigger file sould be touched before, # or in the middle of the PostgreSQL start process, it would get # removed automatically. # # The following variables need to be set only if the agent runs in a # failover zone # # ZONE - Zonename where the zsmf component should be registered # ZONE_BT - Resource name of the zone boot component # PROJECT - A project in the zone, that will be used for the PostgreSQL # smf service. # If the variable is not set it will be translated as :default for # the smf credentialss. # Optional # RS=rolechg-rs RG=rolechg-rg PORT=5432 LH=pgslh-1 HAS_RS= STDBY_RS=des-sta-rs PRI_RS=des-pri-rs STDBY_HOST=zoneb STDBY_PFILE=/pgs/pfile-pgs-standby-rs TRIGGER=/pgs/data/failover WAIT=30 # failover zone specific options ZONE= ZONE_BT= PROJECT=