PostgreSQL-8.1.3

Introduction to PostgreSQL

PostgreSQL is an advanced object-relational database management system (ORDBMS), derived from the Berkeley Postgres database management system.

Package Information

PostgreSQL Dependencies

Optional

Python-2.4.4, Tcl-8.4.13, OpenSSL-0.9.8d, Linux-PAM-0.99.4.0, krb4, MIT Kerberos V5-1.6 or Heimdal-0.7.2, and Bonjour

Optional (To Regenerate Documentation)

DocBook SGML DTD-4.4, DocBook DSSSL Stylesheets-1.79, OpenJade-1.3.2, and SGMLSpm-1.03ii

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/postgresql

Installation of PostgreSQL

Install PostgreSQL with the following commands:

sed -i "s|dsssl-stylesheets|& \\\\\n        sgml/docbook/&-1.79|" \
    configure &&
./configure --prefix=/usr --enable-thread-safety &&
make

To test the results, issue: make check.

Now, as the root user:

make install &&
chown -v root:root /usr/share/doc/postgresql/html/* &&
install -v -m755 -d /usr/share/doc/postgresql/{FAQ/html,TODO.detail} &&
install -v -m644 doc/TODO /usr/share/doc/postgresql &&
install -v -m644 doc/FAQ* /usr/share/doc/postgresql/FAQ &&
install -v -m644 doc/src/FAQ/* /usr/share/doc/postgresql/FAQ/html &&
install -v -m644 doc/TODO.detail/* \
    /usr/share/doc/postgresql/TODO.detail
[Note]

Note

If you are upgrading an existing system and are going to install the new files over the old ones, then you should back up your data, shut down the old server and follow the instructions in the official PostgreSQL documentation.

Initialize a database cluster with the following commands issued by the root user:

install -v -m755 -d /srv/pgsql/data &&
groupadd -g 41 postgres &&
useradd -c "PostgreSQL Server" -g postgres -d /srv/pgsql/data \
        -u 41 postgres &&
chown -v postgres /srv/pgsql/data &&
su - postgres -c '/usr/bin/initdb -D /srv/pgsql/data'

As the root user, start the database server with the following command:

su - postgres -c '/usr/bin/postmaster -D /srv/pgsql/data > \
    /srv/pgsql/data/logfile 2>&1 &'

Still as user root, create a database and verify the installation:

su - postgres -c '/usr/bin/createdb test' &&
echo "create table t1 ( name varchar(20), state_province varchar(20) );" \
    | (su - postgres -c '/usr/bin/psql test ') &&
echo "insert into t1 values ('Billy', 'NewYork');" \
    | (su - postgres -c '/usr/bin/psql test ') &&
echo "insert into t1 values ('Evanidus', 'Quebec');" \
    | (su - postgres -c '/usr/bin/psql test ') &&
echo "insert into t1 values ('Jesse', 'Ontario');" \
    | (su - postgres -c '/usr/bin/psql test ') &&
echo "select * from t1;" | (su - postgres -c '/usr/bin/psql test')

Command Explanations

sed -i "s|dsssl-stylesheets|...": This command puts an extra line in the configure script so that the BLFS installed version of the DSSSL stylesheets are discovered.

--enable-thread-safety: This switch makes the client libraries thread-safe by allowing concurrent threads in libpq and ECPG programs to safely control their private connection handles.

chown -R root:root /usr/share/doc/postgresql/html/*: This command corrects the improper ownership of documentation files.

groupadd ...; useradd ...: These commands add an unprivileged user and group to run the database server.

createdb test; create table t1; insert into t1 values...; select * from t1: Create a database, add a table to it, insert some rows into the table and select them to verify that the installation is working properly.

Configuring PostgreSQL

Config Files

$PGDATA/pg_ident.con, $PGDATA/pg_hba.conf and $PGDATA/postgresql.conf

The PGDATA environment variable is used to distinguish database clusters from one another by setting it to the value of the directory which contains the cluster desired. The three configuration files exist in every PGDATA/ directory. Details on the format of the files and the options that can be set in each can be found in file:///usr/share/doc/postgresql/html/index.html.

Boot Script

Install the /etc/rc.d/init.d/postgresql init script included in the blfs-bootscripts-20060910 package.

make install-postgresql

Contents

Installed Programs: clusterdb, createdb, createlang, createuser, dropdb, droplang, dropuser, ecpg, initdb, ipcclean, pg_config, pg_controldata, pg_ctl, pg_dump, pg_dumpall, pg_resetxlog, pg_restore, pltcl_delmod, pltcl_listmod, pltcl_loadmod, postgres, postmaster, psql, and vacuumdb
Installed Libraries: libecpg.{so,a}, libecpg_compat.{so,a}, libpgport.a, libpgtypes.{so,a}, libpq.{so,a}, and various charset modules.
Installed Directories: /srv/pgsql, /usr/include/libpq, /usr/include/postgresql, /usr/lib/postgresql, /usr/share/doc/postgresql, and /usr/share/postgresql

Short Descriptions

clusterdb

is a utility for reclustering tables in a PostgreSQL database.

createdb

creates a new PostgreSQL database.

createlang

defines a new PostgreSQL procedural language.

createuser

defines a new PostgreSQL user account.

dropdb

removes a PostgreSQL database.

droplang

removes a PostgreSQL procedural language.

dropuser

removes a PostgreSQL user account.

ecpg

is the embedded SQL preprocessor.

initdb

creates a new database cluster.

ipcclean

removes shared memory and semaphores left over by an aborted database server.

pg_config

retrieves PostgreSQL version information.

pg_controldata

returns information initialized during initdb, such as the catalog version and server locale.

pg_ctl

controls stopping and starting the database server.

pg_dump

dumps database data and metadata into scripts which are used to recreate the database.

pg_dumpall

recursively calls pg_dump for each database in a cluster.

pg_resetxlog

clears the write-ahead log and optionally resets some fields in the pg_control file.

pg_restore

creates databases from dump files created by pg_dump.

pltcl_delmod

is a support script used to delete a module from a PL/Tcl table. The command requires the Pgtcl package to be installed also.

pltcl_listmod

is a support script used to list the modules in a PL/Tcl table. The command requires the Pgtcl package to be installed also.

pltcl_loadmod

is a support script used to load a module into a PL/Tcl table. The command requires the Pgtcl package to be installed also.

postgres

is a single user database server, generally used for debugging.

postmaster

is a multi-user database daemon.

psql

is a console based database shell.

vacuumdb

compacts databases and generates statistics for the query analyzer.

Last updated on 2007-01-28 10:12:24 -0600