Contents / Previous / Next


PostgreSQL Installation

Install RPMs: postgresql postgresql-docs and postgresql-server.

Recompilation (usually is not necessary):
shell> ./configure; gmake; su; gmake install;

Create Database Cluster
A single directory under which all databases will be stored
(also called database storage area or SQL catalog cluster).

One cluster will be accessible through one single running database server.
Every user may run his own server and store his databases in his home directory
(alternatively add a postgres-user and run one server for everybody): shell> initdb -D /home/fred/database/postgresql/data After this initialization, the database cluster will contain one database named template1,
the user that is currently loged in is the owner (fred).

Starting the Server
Again, the current user starts the server: shell> /usr/bin/pg_ctl -D /home/fred/database/postgresql/data \ -l /home/fred/tmp/logfile start or shell> /usr/local/pgsql/bin/postmaster \ -D /home/fred/database/postgresql/data \ >/home/fred/tmp/logfile 2>&1 & or (export POSTGRES_DATADIR=/home/fred/database/postgresql/data) shell> /etc/init.d/postgresql start

Server, Client Connection Trouble ??
If you cannot connect because, e.g., "USER fred DOES NOT EXIST!",
the reason might be that another server was already running when you started your postmaster (check with: ps -ef | grep postmaster). In this case psql tries by default to connect to the first server, which listens to the default port (port 5432, see /etc/services).
Solution: Start your server on an other port, e.g., port 5433 (not assigned). Try (you are fred): SHELL> initdb -D /home/fred/database/postgresql/data SHELL> /usr/bin/postmaster -p 5433 \ -D /home/fred/database/postgresql/data SHELL> psql -p 5433 template1 initdb needs to be run only once.
Do not forget to kill (stop) the server again before you log out.

Killing the Server
Find the postmaster PID with ps or get it from the file "postmaster.pid" in the data directory and kill: shell> kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid` or shell> pg_ctl stop or shell> /etc/init.d/postgresql stop

Creating a Database and Starting the psql Client
Use the createdb shell script to create a database named "testbase": shell> /usr/local/pgsql/bin/createdb testbase or Start the postgresql client on the pre-installed template1 database: psql template1 and create a new database from the client shell: create database testbase;


Configuration


Network Login:
The alow the login from an other machine (IP adrress) or network (subnet and mask) on the internet, you have to edit the file pg_hba.conf (n the database cluster), and add a line like (141.64.40.72 is orinoco.tfh-berlin.de):
# TYPE  DATABASE  IP_ADDRESS    MASK               AUTH_TYPE  AUTH_ARGUMENT
host    all       141.64.40.72  255.255.255.255    trust


Run-time Configuration: postgresql.conf File

The postgresql.conf file is in the data directory.
It is reread whenever the postmaster receives a SIGHUP signal (use pg_ctl reload).

Command-line options override any conflicting settings in postgresql.conf.
They can also be changed in individual SQL sessions with the SET command.