Friday, August 28, 2009

Installing PostgreSQL on Linux using RPMs

Downloading the RPMs :
As I mentioned in the previous post the RPMs are available on PostgreSQL FTP site and all of its mirrors.
  • Select version of Postgres to Install
  • Select Platform - Linux
  • Select rpm / srpm
  • Select Linux Flavour (redhat/fedora)
  • Download RPMs Listed there
Installing and Upgrading PostgreSQL RPMs :
  • Installing PGDG RPMs are as easy as installing any RPMs
    rpm -ivh package_name.version.arch.rpm
  • Unless specified, on minor release upgrades (i.e., upgrading from 8.1.0 to 8.1.1 or 8.1.3, etc1), you may use usual RPM upgrade process :
    rpm -Uvh package_name.version.arch.rpm
  • Please note that on every new major version upgrade, youhave to follow dump/reload sequence.
Sequence of RPMs to Install :
  1. rpm -ivh postgresql-libs-8.3.7-1PGDG.rhel5.i386.rpm
  2. rpm -ivh postgresql-debuginfo-8.3.7-1PGDG.rhel5.i386.rpm
  3. rpm -ivh postgresql-8.3.7-1PGDG.rhel5.i386.rpm
  4. rpm -ivh postgresql-devel-8.3.7-1PGDG.rhel5.i386.rpm
  5. rpm -ivh postgresql-docs-8.3.7-1PGDG.rhel5.i386.rpm
  6. rpm -ivh postgresql-server-8.3.7-1PGDG.rhel5.i386.rpm
Creating the Cluster using initdb :
  1. Open Terminal
  2. su - postgres (changes your identity from root user to postgreSQL super user)
  3. Move to /opt/PostgresPlus/8.3/bin using "cd /opt/PostgresPlus/8.3/bin"
  4. execute "initdb -D data" (creates the Cluster, a new directory named 'data')
To work in with your Database :
  1. Start Cluster using "pg_ctl -D start"
  2. To Chech the status use "pg_ctl status"
  3. Login inside the Cluster using "psql" command (continue your work in DataBase)
  4. reload : to reload the server configurations
  5. restart : to restart (stop/start) Server
  6. To stop the Cluster use "initdb -D stop"
Advance Settings :
Now every time you need to go to /opt/PostGresPlus/8.3/bin folder to execute the commands like psql, pg_ctl, etc., instead of doing this activity every time we can set the environment variables like PATH, PGDATA, PGPORT in .bash_profile file of User (postgres User)

Steps to follow :
  1. open Terminal
  2. Login as postgres User
  3. open .bash_profile file using "vi .bash_profile"
  4. insert the Lines PATH= PGDATA= PGPORT= and save the file
  5. now you can run all postgres commands from any location from terminal as postgres user
we'll see these things in detail in the next post....

No comments:

Post a Comment

Followers