PostgreSQL

Installation

download source file (postgresql-8.1.1.tar.gz) to /tmp.

Uncompress:

cd /tmp
gunzip postgresql-8.1.1.tar.gz
tar -xf postgresql-8.1.1.tar
cd postgresql-8.1.1

Compilation and installation:

./configure
make
make install

Setting

Create user postgres:

adduser postgres

Initialize database directory:

mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

Edit /usr/local/pgsql/data/pg_hba.conf if you want to allow remote connections to database server.

Start PostgreSQL server

You must be postgres user.

/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data > /var/log/postgresql.log 2>&1 &

Create first database

Create first database:

/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test

Create example database, user, table and grant access

bash command to start PostgreSQL database interface:

psql template1

Create database:

CREATE DATABASE monitor;

Create database user monitor

CREATE USER monitor WITH PASSWORD 'password';

Exit database template1 and enter database monitor:

\q
psql monitor

Create table logs and grant access for user monitor to table logs:

CREATE TABLE logs (
                    source      VARCHAR(120),
                    application VARCHAR(120),
                    description VARCHAR(600),
                    ltime       TIMESTAMP,
                    saverity    SMALLINT,
                    priority    SMALLINT,
                    message     VARCHAR(6000),
                    stime       TIMESTAMP,
                    usr         VARCHAR(2000)
);

GRANT SELECT, INSERT, UPDATE, DELETE ON logs TO monitor;

Define new procedural language (for examle plpgsql).

/usr/local/pgsql/bin/createlang plpgsql monitor;
 
postgres.txt · Last modified: 31.03.2010 17:51 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki