Saturday, September 7, 2013

PostgreSQL Data Base Installation

PostgreSQL, often simply Postgres, is an open source object-relational database management system (ORDBMS) with an emphasis on extensibility and standards compliance. 
The article tells you how to install the PostGre SQL database in linux and start working with it.

Download the PostgreSql 8.8.8-1 for the Linux Distribution from Here

Now we need to install the Postgresql with a different userID rather that root. Create a new User With name Postgres.

adduser postgres
passwd postgres

Once you have created the postgres userID and defined a password to it. Login in using the postgres user ID and install the Postgresql database.

For installation just go the location where the Postgresql was downloaded and run the command like

./postgresql-8.4.8-1-linux.bin

Once the command is executed, you can see the installation of database is started.

It will be installed to /opt location if you select the default location to install.
Now once the installation is done, we now configure the PostgreSql server that suits for the RHQ server.

Execute the initdb command for postgresql from bin location like,

./initdb -D opt/PostgreSQL/8.4/data

It executes and shows the following output

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to "english".

creating directory opt/PostgreSQL/8.4/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in opt/PostgreSQL/8.4/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
.
.
.
Success. You can now start the database server using:
    ./postgres -D opt/PostgreSQL/8.4/data
or
    ./pg_ctl -D opt/PostgreSQL/8.4/data -l logfile start

Once this is executed, start the Server using postgres command from bin like,
./postgres -D opt/PostgreSQL/8.4/data &

This shows the following output,
[postgres@vx111a bin]$ ./postgres -D opt/PostgreSQL/8.4/data &
[postgres@vx111a bin]$ LOG:  database system was shut down at 2011-08-29 04:43:35 EDT
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections

While starting the Server, it may throw some security exceptions, at that point execute the below command as root,

chcon -t textrel_shlib_t '/opt/PostgreSQL/8.4/lib/libedit.so'

By this the server is up and running. Now we will create a user and Database by which we can login to server.

From the same bin location, execute command to create user
./createuser -h 127.0.0.1 -p 5432 -U postgres -S -D -R rhqadmin

And execute command to create a Database
./createdb -h 127.0.0.1 -p 5432 -U postgres -O rhqadmin rhq

By this the Installation of Database is done.