Chapter 2. Installing PostgreSQL

Table of Contents
Preparing for Installation
10 Steps to PostgreSQL Installation

This chapter focuses on the requirements and steps involved with installing and configuring PostgreSQL. Many of the PostgreSQL capabilities are not enabled by default. This is especially true of certain languages extensions such as TCL. As many of the features are not configured by default we will cover the various flags and options available to you at compile time. It is important that you carefully read through all the steps.

NotePostgreSQL for Windows
 

Although PostgreSQL is capable of running on a Win32 platform, this book will not cover installation for Windows. The Win32 version of PostgreSQL requires the Cygwin environment and will not operate independently within Win32. Although the use of Cygwin can be useful in many situations, the use of a PostgreSQL in a Cygwin environment is probably best left to development and testing only. Accordingly, this chapter will walk you through the installation steps on a Unix/Linux platform. Our installation platform is Linux, but these instructions should be compatible with most current Unix platforms.

Preparing for Installation

The installation of PostgreSQL is not difficult. However, there are some software requirements that you will need for the PostgreSQL compilation. All of the requirements, outside of the PostgreSQL source code are GNU tools. If you are running Linux, there is a good chance that the tools are already installed. If you are running a BSD derivative such as FreeBSD or MacOS X you may have to download the tools. If you find that you are missing any of the required components, first check your vendor website for the packages, otherwise you may download them from http://www.gnu.org. The following is a list of required packages.

Installation Requirements

GNU make

GNU make is commonly known as gmake but is normally referred to as make on GNU based systems such as Linux.

NoteNote
 

For consistency we will refer to the GNU make as gmake throughout the rest of this book.

We recommend that you use at least GNU make version 3.76.1 or higher when compiling PostgreSQL. To verify the existence and correct version number of GNU make, type the following at the command line:

Example 2-1. Verifying GNU Make

[user@host user]$ gmake --version
GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
Built for i386-redhat-linux-gnu
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
        Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
 
Report bugs to <bug-make@gnu.org>.
 
[user@host user]$
ISO/ANSI C Compiler

There are numerous ISO/ANSI C compilers available. The recommended compiler for compiling PostgreSQL is the GNU C Compiler, although PostgreSQL has been known to build with compilers from different vendors. At the time of this writing, the most commonly distributed versions of GCC are 2.95 and 2.96 (RedHat Linux 7.x and Mandrake Linux 8.x) . If you currently do not have GCC installed you can download it by visiting the GNU website at: http://gcc.gnu.org/

To check for the existence and version of GCC, you can type the following at the command line:

Example 2-2. Verifying GCC

[user@host user]$ gcc --version
2.95.3
[user@host user]$
Available Disk Space

PostgreSQL does not require the extensive use of resources. In fact, in comparison to products such as Oracle, PostgreSQL could be considered fat-free. However, PostgreSQL is a database, and as with any database the the requirements will grow as you continue to use PostgreSQL.

On a RedHat Linux 6.2 machine you will need approximately 50 megabytes of hard drive to unpack the source and 60 megabytes of hard drive space to compile. If you choose to run the regression tests you will need approximately an additional 30 megabytes. Depending on the configuration options you choose PostgreSQL can take anywhere from 8 and 15 megabytes of hard drive space once installed.

NoteRemember Disk Space
 

PostgreSQL's space requirements will grow as you use it.

Trying to install on a system lacking in necessary space is potentially dangerous! Before installing PostgreSQL it is recommended that you check your filesystem for enough disk space in your intended installation partition (e.g., /usr/local). If you have a GNU-based system, the df command should be at your disposal.

Example 2-3. Verifying Disk Space

[user@host user]$ df -k
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda1              2355984    932660   1303644  42% /
/dev/hdb1              4142800   2133160   1799192  54% /home
/dev/hda6              1541680    272540   1190828  19% /usr/local
[user@host user]$
GNU zip and tar

GNU zip is also called gzip. Gnu zip is a compression utility which can compress as well as decompress files. All compressed, or "zipped", files made with gzip have a ".gz" extension. You can test for the existence of the gzip program with the gzip --version command.

In addition to gzip, you will require a copy of tar, a utility used to group several files and directories into a single archive, as well as to unpack these archives onto the filesystem. An archived tar output file will typically contain a ".tar" extension. Files which are both archived by tar and compressed by gzip often have a ".tar.gz" compound extension, as is the case with the included PostgreSQL source distribution. You can test for tar with the tar --version command.

Example 2-4. Verifying gzip and tar

[user@host user]$ gzip --version
gzip 1.3
(1999-12-21)
Copyright 1999 Free Software Foundation
Copyright 1992-1993 Jean-loup Gailly
This program comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of this program
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Compilation options:
DIRENT UTIME STDC_HEADERS HAVE_UNISTD_H HAVE_MEMORY_H HAVE_STRING_H
Written by Jean-loup Gailly.

[user@host user]$ tar --version
tar (GNU tar) 1.13.17
Copyright 2000 Free Software Foundation, Inc.
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by John Gilmore and Jay Fenlason.
[user@host user]$

Optional Packages

The following are some optional packages that you may want to have installed:

GNU Readline Library

The GNU Readline library greatly increases the usability of psql, the standard PostgreSQL command-line console client. It adds all of the standard functionality of the GNU Readline library to the psql command line, such as being able to easily modify, edit and retrieve command history information with the arrow keys, and reverse-i-search. If the Readline libraries are already installed on your system, the configuration process should automatically compile readline support withpsql.

NoteNetBSD Users
 

You may not need this package if you have NetBSD, as NetBSD has a libedit library which provides readline compatibility.

OpenSSL

OpenSSL is an Open Source implementation of the SSL/TLS protocols. OpenSSL is commonly used with utilities such as OpenSSH and Apache-SSL. PostgreSQL can make use of OpenSSL for encrypted connectivity between the psql client application and the PostgreSQL backend. You may also want to consider OpenSSL if you wish to use Stunnel which is discussed later on in the book. You can find out more information on OpenSSL at: http://www.openssl.org/

TCL/TK

TCL/TK is a combination programming language and graphical toolkit. Although we don't cover extensive use of TCL with PostgreSQL, we do cover the use of PgAccess. If you wish to utilize the PgAccess application you will need to install the TCL/TK software. The website for TCL/TK is: http://tcl.activestate.com/

Linux

Because everyone should run Linux!