wiki:sysadminPostgreSQLConfiguration

Version 2 (modified by risard, 13 years ago) (diff)

--

Installing Postgres


Overview

PostgreSQL is a powerful object-relational open source database server. Evergreen uses Postgres as its backend datastore. Earlier versions of Evergreen used version 8.2, currently (post v1.4) Evergreen uses Postgresql 8.3. The instructions below are for installing 8.3. See the references below for instructions on installing version 8.2 if you're using an older version of Evergreen.

The assumption being made in this documentation, is that the database server is separate from the open-ils server.


Installing the Software

Postgres is a common default install on most distros and might already be installed. As root (using either sudo or su), run apt to see:

    sudo apt-get update
    sudo apt-get install postgresql-8.3

If postgres is already installed, apt will say so and make no changes, otherwise it will be installed with default settings.

During installation,a postgres user will be added to the local system (ie the computer). This is a standard linux user account and it's permissions are created during setup. Do not change the permissions of this user! This user runs the postgres processes and should have only the permissions necessary to do that. Also created during installation is a db role called postgres. This is internal to postgres and has nothing to do with the operating system. The postgres role provides complete access to all databases created on that db server. It's important to change the passwords for both the postgres account and postgres role for security purposes.

    $sudo passwd postgres

You will be prompted to change postgres's password. After doing so, you can check that it worked by trying:

    $su postgres

You should gain access to the postgres account with the password you entered. If not, you likely made a mistake and can try again with the passwd command.

You change the db role via psql. Switch users to postgres:

    $su postgres

and log into psql:

    $psql

Run the following:

    ALTER ROLE postgres WITH ENCRYPTED PASSWORD 'mypassword';  #include the quotes around mypassword

Initializing The Database Server

Postgres uses the term "database cluster" to describe the directory it uses to store data. During the apt install, a default directory is created, usually at: /var/lib/postgresql/8.3/main.

NOTE: our servers have been partitioned to best serve the needs of Evergreen. The default cluster location is not usually on a partition that has been sized appropriately for the db. Generally, you will not be using the default install directory.

You will need to find the appropriate partition and install the appropriate files there. This is usually:

    /data/postgresql/8.3/