Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

This page is user contributed documentation. See the bottom of the page for information about the author.  

Installing PostgreSQL 7.2.1 on Solaris 7/8

Server only installation

Aim

To install PostgreSQL 7.2.1 on an existing Solaris 7/8 server (SPARC or INTEL), with no optional GUI based extensions.

Assumptions

This document assumes you have full root access to the server you will be installing PostgreSQL on, it doesn't have an existing 'postgres' user nor 'postgres' group present, and you have the necessary authorisation to reboot the server where needed.

This document also assumes you don't have GNU binutils installed, and are therefore using the Solaris linker (ld), not the GNU one.

Software required to be already installed

gcc 2.95.x (2.95.3 recommended, haven't tried gcc 3.x.x)
perl 5
GNU make

Software these instructions will install

PostgreSQL 7.2.1
OpenSSL 0.9.6b
GNU Readline 4.1
The 713solaris78-startup PostgreSQL startup script from this site.

The checklist

General instructions that compile properly and find the readline libraries.
Semaphore and shared memory updates to /etc/system
Unix domain sockets workaround
OpenSSL 0.9.6 and previous workaround for des_encrypt() clash
OpenSSL 0.9.6a workaround for the shared library Makefile problem
Startup script
PostgreSQL buffer and startup options for optimum performance
(Need to establish optimal Solaris PostgreSQL database sizing techniques before this can be completed)
Basic pg_hba.conf configuration options
Solaris INTEL instructions for building the readline libraries (same as SPARC ones).
Ensure the compilation options strip out unneeded symbols and provide for relocation with $ORIGIN.
Add largefile support, so tools like pg_dump will work

Installation details

  1. Set the correct environment variables for OpenSSL compilation
    $ unset LD_LIBRARY_PATH LD_RUN_PATH
    $ PATH=$PATH:/usr/ccs/bin
    $ LD_OPTIONS='-R$ORIGIN/../lib'
    $ export PATH LD_OPTIONS

  2. Configure OpenSSL 0.9.6b
    $ ./config --prefix=/opt/openssl threads shared

  3. For OpenSSL 0.9.6a we need to update its Makefile to correctly create shared libraries
    (If you are compiling a version of OpenSSL prior to 0.9.6a, you don't need to follow this step)
    $ sed "s/SHLIB_TARGET=gnu-shared/SHLIB_TARGET=solaris-shared/" Makefile.ssl > Makefile.tmp
    $ mv Makefile.tmp Makefile.ssl

  4. Compile and install OpenSSL
    $ make
    $ make test
    $ su
    # make install
    # exit

  5. Set the correct environment variables for compiling GNU readline 4.1
    $ unset LD_LIBRARY_PATH LD_RUN_PATH
    $ LD_OPTIONS='-R$ORIGIN/../lib'
    $ export LD_OPTIONS

  6. Compile and install GNU readline 4.1
    $ ./configure
    $ make shared
    $ su
    # make install
    # make install
    (for some reason this seems to sometimes need to be run a second time)
    # exit

  7. Update the /etc/system file to have decent shared memory and semaphore limits
    Before you do this, check in your /etc/system file if you already have values for these settings there.  If so, you may not need these ones.  Newly installed servers will need these values though.
    (These values are copied straight from the PostgreSQL documentation here.  They work but may not be optimal).
    $ su
    # echo set shmsys:shminfo_shmmax=0x2000000 >> /etc/system
    # echo set shmsys:shminfo_shmmin=1 >> /etc/system
    # echo set shmsys:shminfo_shmmni=256 >> /etc/system
    # echo set shmsys:shminfo_shmseg=256 >> /etc/system
    # echo set semsys:seminfo_semmap=256 >> /etc/system
    # echo set semsys:seminfo_semmni=512 >> /etc/system
    # echo set semsys:seminfo_semmsl=32 >> /etc/system
    # echo set semsys:seminfo_semmns=512 >> /etc/system

  8. Reboot so the shared memory and semaphore limits take effect
    # shutdown -g0 -y -i6

  9. Create the 'postgres' user group
    # groupadd postgres

  10. Create the 'postgres' user
    # useradd -d /opt/pgsql -m -s /bin/sh -g postgres postgres

  11. Set the 'postgres' user account password
    # passwd postgres
    (If you want to lock access to the account to everyone except 'root' use "passwd -l postgres")

  12. Create the directory PostgreSQL will be installed into
    # mkdir -p /opt/pgsql/7.2.1
    # chown postgres:postgres /opt/pgsql/7.2.1

  13. Log in as the 'postgres' user
    # su - postgres

  14. Create the correct environment variables for the postgres user
    $ echo "PGHOME=/opt/pgsql/7.2.1" >> .profile
    $ echo "PGDATA=$PGHOME/data" >> .profile
    $ echo "PGLIB=$PGHOME/lib" >> .profile
    $ echo "PATH=$PATH:$PGHOME/bin" >> .profile
    $ echo "MANPATH=$PGHOME/man" >> .profile
    $ echo "export PGHOME PGDATA PGLIB PATH MANPATH" >> .profile

  15. Set the correct environment variables for PostgreSQL 7.2.1 compilation
    $ unset LD_LIBRARY_PATH LD_RUN_PATH
    $ LD_OPTIONS='-L/usr/local/lib -R$ORIGIN/../lib -R/opt/openssl/lib -R/usr/local/lib -i -s -z origin'
    $ CFLAGS="`/bin/getconf LFS_CFLAGS` -O2 -funroll-loops -fexpensive-optimizations -I/usr/local/include"
    $ CPPFLAGS="`/bin/getconf LFS_CFLAGS` -O2 -funroll-loops -fexpensive-optimizations -I/usr/local/include"
    $ PATH=$PATH:/usr/ccs/bin
    $ export CFLAGS CPPFLAGS LD_OPTIONS PATH
    (If you are running Solaris INTEL and have a Pentium II or above processor, you can add "-mcpu=i686" to the above CFLAGS and CPPFLAGS lines for greater optimisation.  If you've got a Pentium, then the appropriate option is "-mcpu=i586").  By the way, with the -O2 up above its the letter O, not the number 0.

  16. Fix the PostgreSQL source code to work with OpenSSL versions prior to 0.9.6a
    If you are already using a version of OpenSSL earlier than 0.9.6a you'll need to update the PostgreSQL source code to work with it.  It's straightforward and the steps are available here.

  17. Fix the PostgreSQL source code to work with GNU readline version 4.2
    If you are compiling PostgreSQL 7.1 instead of PostgreSQL 7.2.1, AND are already using GNU readline 4.2, AND therefore didn't need the above instructions for installing GNU readline 4.1, you will need to update the PostgreSQL 7.1 source code to work with it.  It's straightforward and the steps are available here.

  18. Compile PostgreSQL 7.2.1
    $ ./configure --prefix=/opt/pgsql/7.2.1 --enable-syslog --with-openssl=/opt/openssl
    $ make

  19. Run the regression tests to make sure the compilation worked
    Firstly though you'll need to edit the src/test/regress/pg_regress.sh script to use TCP instead of UNIX domain sockets
    $ cd src/test/regress
    $ sed "s/beos/beos\* | \*solaris/" pg_regress.sh > pg_regress.tmp
    $ mv pg_regress.tmp pg_regress.sh
    $ cd ../../..
    $ make check

  20. If there were no regression test failures, install PostgreSQL
    $ make install

  21. Initialise the database
    $ initdb -D /opt/pgsql/7.2.1/data

  22. Change the pg_hba.conf file to allow connections from other machines as appropriate (optional, check the manual)
    The text in blue needs to be replaced with the correct values
    $ cd /opt/pgsql/7.2.1/data/
    $ echo -e "host\tall\t<ip address of other machine or subnet>\t<netmask of other machine or subnet>\t<authentication method>" >> pg_hba.conf

  23. Create the logfile directory for debug messages to arrive in
    $ su
    # mkdir /var/log/pgsql
    # chown postgres:postgres /var/log/pgsql

  24. Install the 713solaris78-startup script in /etc/init.d
    # cp 713solaris78-startup /etc/init.d/postgresql

    Due to time constaints I haven't updated this script for PostgreSQL 7.2.1.  You need to edit it with a text editor and change all the references of "7.1.3" to "7.2.1"

    # chown root:sys /etc/init.d/postgresql
    # chmod 744 /etc/init.d/postgresql

  25. Create symbolic links to the postgresql startup script so it starts and stops automatically alongside the system
    # ln -s /etc/init.d/postgresql /etc/rc3.d/S05postgresql
    # ln -s /etc/init.d/postgresql /etc/rc0.d/K30postgresql

  26. Start the PostgreSQL server, using the newly installed startup script
    # /etc/init.d/postgresql start

  27. Ensure the PostgreSQL server is running
    # ps -ef | grep postmaster
    (you should see an entry for the "postmaster" program.  This means it's running.)
    # exit
    $
Updated: 2006-04-04 11:59
Author: Robert Treat
Long time PostgreSQL Contributor, Co-Author of Begining PHP and PostgreSQL 8
Version history:
  • 2006-04-03, Robert Treat
Operations: Edit Create subpage (Requires community login)

Privacy Policy | Project hosted by hub.org | Designed by tinysofa
Copyright © 1996 – 2007 PostgreSQL Global Development Group