Tuesday, February 07, 2012

Installation of PostgreSQL

Install through yum:

download pgdg-<system>-8.4-2.noarch.rpm file from http://yum.pgsqlrpms.org/reporpms/8.4/

[root@system ~]# rpm -ivh pgdg-<system>-8.4-2.noarch.rpm
[root@system ~]# yum -y install postgresql-server postgresql postgresql-libs
or
[root@system ~]# yum -y update postgresql-server postgresql postgresql-libs

Install through apt-get:

[root@system ~]# apt-get install postgresql

For manual installation:

Download the .rpm or .deb file(s) and save it to disk.
Binary Distributions: http://www.postgresql.org/download/linux

Install:

[root@system ~]# rpm -ivh postgresql-<version>.rpm postgresql-server-<version>.rpm postgresql-libs-<version>.i386.rpm

or

[root@system ~]# dpkg -i postgresql-<version>.deb
Initialization of PostgreSQL server:
[root@system ~]# service postgresql initdb
[root@system ~]# chkconfig --level 345 postgresql on
Configuration:

edit the file /var/lib/pgsql/data/pg_hba.conf replase the line

host    all         all         127.0.0.1/32          ident
with this one
host    all         all         127.0.0.1/32          md5
Starting of PostgreSQL server:
[root@system ~]# service postgresql start
Logon into the PostgreSQL server:
[root@system ~]# su postgres
[root@system ~]$ psql postgres
could not change directory to "/root"
psql (8.4.2)
Type "help" for help.
Create PostgreSQL user:
postgres=#CREATE USER vpnttg SUPERUSER;
CREATE ROLE
postgres=#ALTER USER vpnttg UNENCRYPTED PASSWORD 'vpnttgpass';
ALTER ROLE
Check of PostgreSQL users:
postgres=#SELECT * FROM pg_shadow;
usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil | useconfig
----------+----------+-------------+----------+-----------+------------+----------+-----------
postgres | 10 | t | t | t | | |
vpnttg | 16384 | f | t | t | vpnttgpass | |
(2 rows)
Logout from the PostgreSQL server:
postgres=# \q
[root@system ~]$ exit
Create of VPNTTG DB:
[root@system ~]# export PGPASSWORD=vpnttgpass
[root@system ~]# createdb vpnttgdb -h 127.0.0.1 -U vpnttg
List of PostgreSQL databases:
[root@system ~]# psql -l -h 127.0.0.1 -U vpnttg
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges
-----------+----------+-----------+-----------+-------+-----------------------
postgres | postgres | SQL_ASCII | C | C |
template0 | postgres | SQL_ASCII | C | C | =c/postgres
: postgres=CTc/postgres
template1 | postgres | SQL_ASCII | C | C | =c/postgres
: postgres=CTc/postgres
vpnttgdb | vpnttg | SQL_ASCII | C | C |
(4 rows)

Download:

Extract:

[root@system ~]# unzip vpnttgdb_v1.6.zip
Initialization of vpnttgdb databas:
[root@system ~]# psql vpnttgdb -h 127.0.0.1 -U vpnttg < vpnttgdb_v1.6.sql
Logon into the vpnttgdb database:
[root@system ~]# psql vpnttgdb -h 127.0.0.1 -U vpnttg
psql (8.4.2)
Type "help" for help.

vpnttgdb=#
Insert the VPN Server's SNMP and OID parameters:
vpnttgdb=# INSERT INTO devices VALUES ('<vpn_server_ip>', '<vpn_server_name>', '<community>', 'ASA');
Logout from the vpnttgdb database:
vpnttgdb=# \q