Monday, 20 July 2015

How to Install Postgresql-9.0.1 by Source file

Download postgresql-9.0.1.tar.gz:
#cd /opt

#wget https://ftp.postgresql.org/pub/source/v9.0.1/postgresql-9.0.1.tar.gz

Installation Postgresql database:

Postgresql installation path = /opt/PostgreSQL/9.0/postgres

#mkdir -p /opt/PostgreSQL/9.0/postgres  /* Create postgres installation directory path*/

#tar -zxvf postgresql-9.0.1.tar.gz         /*extract postgresql software*/

# cd postgresql-9.0.1            /*Go to Source of postgresql source Directory */

#./configure --prefix=/opt/PostgreSQL/9.0/postgres     /*Configuration with installation path*/

#make        /*Compile the postgresql and postgresql.log will be created*/

#make install

Set postgresql environment path:

edit .bash_profile
#cd

#vi .bash_profile

Original .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:
export PATH
---------------------------------------------------EOF-------------------------------

Change .bash_profile as follows:

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/opt/PostgreSQL/9.0/posgres/bin:
LD_LIBRARY_PATH=/opt/PostgreSQL/9.0/postgres/lib
export PATH LD_LIBRARY_PATH
---------------------------------------------------EOF-------------------------------

#source .bash_profile        /*source the bash profile*/

#which postgres         /*verify the installation path*/

Create postgres user with /opt/PostgreSQL/9.0/postgres home directory:

#useradd  -b /opt/PostgreSQL/9.0  postgres
       
#passwd postgres    /*set password for postgres user*/

#mkdir /opt/PostgreSQL/9.0/postgres/data /*create postgres data directory for initiating database*/

change ownership of postgres of data directory:

#chown -R postgres  /opt/PostgreSQL/9.0/postgres/data    

Go to postgres user and initiate database:

#su – postgres

#/opt/PostgreSQL/9.0/postgres/bin/initdb  -D  /opt/PostgreSQL/9.0/postgres/data  /*Initiating database*/

#/opt/PostgreSQL/9.0/postgres/bin/postgres -D /opt/PostgreSQL/9.0/postgres/data/ > /opt/PostgreSQL/9.0/postgres/logfile/ 2>&1 & /*Start database server*/

No comments:

Post a Comment