Install postgresql using source code

Today I have installed postgresql 9.5.2 in REDHAT 6. Below are the steps to install postgresql.

1) Create postgresql user

useradd postgres
passwd postgres

2) Create the required directories to install postgres ( This is according to my configuration)

mkdir /arc_dep_post
mkdir /postgres
mkdir /DATA

3) download the postgresql source code from http://www.postgresql.org/ftp/source/v9.5.2/.

4) untar the source code

tar xvf

Installation steps

1) Configure 

Go to the build directory , execute the below command to configure the server with required options.

./configure –prefix=/postgres –exec-prefix=/arc_dep_post –with-pgport=1818 –with-segsize=4 –with-wal-segsize=8 –with-wal-blocksize=4

–prefix option is used to mention the location where to install the software
–exec-prefix option to install the architecture(OS) dependent software location
–with-pgport option specify the port number
–with-segsize option specify the size of the segment. Postgres store the data in terms of segments (os level files) each segment is a file. This is in terms of GB.
–with-wal-segsize option specify the size of the wal segment in MB.
–with-wal-blocksize option specify the size of the block size in KB

checking build system type… x86_64-pc-linux-gnu
checking host system type… x86_64-pc-linux-gnu
checking which template to use… linux
checking whether to build with 64-bit integer date/time support… yes
checking whether NLS is wanted… no
checking for default port number… 1818
checking for block size… 8kB
checking for segment size… 4GB
checking for WAL block size… 4kB
checking for WAL segment size… 8MB
checking for gcc… gcc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… no
checking for suffix of object files… o
…………………………………..
…………………………………..
…………………………………..
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port

[postgres@localhost postgresql-9.5.2]$ echo $?
0

2)  execute the command “make”

make

At the end we can see the message

All of PostgreSQL successfully made. Ready to install.

3) make install

At the end you will get a message “PostgreSQL installation complete.” This will use the directories mentioned in the first step.

Post-installation steps :-

set the variables  in profile file.

[postgres@localhost Desktop]$ cat ~/.profile
export PATH=$PATH:/arc_dep_post/bin
export LD_LIBRARY_PATH=/postgres/include/server/lib

Errors I faced :-

configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn’t looking in the proper directory.
Use –without-readline to disable readline support.

Sol :-

Install the readline library. Readline is used to store the history of commmands in psql prompt.

configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn’t looking in the proper directory.
Use –without-zlib to disable zlib support.

Sol :-

Install the zlib packages(zlib,zlib-devel). if you do not install this package , it will prevents use of the Zlib library. This disables support for compressed archives in pg_dump and pg_restore.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s