Install Postgres 8 on Centos

How to Install Postgres 8 on RHEL/Centos in 3 minutes

I want to share quick and specific instructions for the installation of the Postgres 8 database on Red Hat Enterprise Linux 5 / Centos 5. I am using Yum for this installation. To make sure that you have everything needed do:
[code lang="shell"]
yum list | grep postresql
[/code]

and verify that you see:
[code lang="shell"]
postgresql.i386, postgresql-server.i386 and postgres-libs.i386 (i386 if on non-64 bit version)
[/code]

Centos installation comes with postgresql-lib installed. If it does not, do:
[code lang="shell"]
yum install postgresql-libs
[/code]

Now, the general installation. As root install postgres core:
[code lang="shell"]
yum install postgresql
[/code]

Install postgres server:
[code lang="shell"]
yum install postgresql-server
[/code]

Now create postgres user:
[code lang="shell"]
adduser postgres
[/code]

Create the datafile for the database:
[code lang="shell"]
mkdir -p /usr/local/pgsql/data
[/code]

Change ownership of the data files to the postgres user:
[code lang="shell"]
chown postgres /usr/local/pgsql/data
[/code]

Now assume the role of a postgres user:
[code lang="shell"]
su - postgres
[/code]

Important note: Installation of the postgres executables on Centos 5 / RHEL 5 is /usr/bin not /usr/local as Postgres official documentation suggests.

Initialize the datafiles for the database:
[code lang="shell"]
/usr/bin/initdb -D /usr/local/pgsql/data
[/code]

Start the database with initialized datafiles as the background process (&) and log all messages and errors (2&1) in the logfile:
[code lang="shell"]
/usr/bin/postgres -D /usr/local/pgsql/data > logfile 2>&1 &
[/code]

Create the test database:
[code lang="shell"]
/usr/bin/createdb test
[/code]

Log in to the test database:
[code lang="shell"]
/usr/bin/psql test
[/code]

You should see "Welcome to Postgres 8..." intro message and prompt:
[code lang="shell"]
test=#
[/code]

Komentarze

Popularne posty z tego bloga

Set up JBoss AS 5.1.0 and Seam 2.2.0 in Ubuntu 9.04