Installation of PostgreSQL Linux using Source Code

Share via:

Installation of PostgreSQL Linux using Source Code:

To begin, connect to the Linux virtual Machine via PuTTY using IP address. To obtain the IP address, log into the virtual machine and enter the command ‘ifconfig’ in the terminal. Now open Putty and enter the IP address of the virtual machine in the “Host Name” field and click on “open”.

You will be prompted to enter your username and password for the Linux virtual machine. Now you are ready to use Linux virtual machine through the Putty terminal.

Installation of PostgreSQL using source code method:

Prerequisites before installing the PostgreSQL:

Before you install the application, it is recommended to check few prerequisites.
  1. [root@postgres1 ~]# make -version
GNU Make 3.81
This program built for x86_64-redhat-linux-gnu
  1. [root@postgres1 ~]# rpm -qagcc
gcc-4.4.7-23.0.1.el6.x86_64
There are also some Optional prerequisites that you may want to check:
  1. [root@postgres1 ~]# rpm -qareadline
readline-6.0-4.el6.x86_64
  1. [root@postgres1 ~]# rpm -qazlib
zlib-1.2.3-29.el6.x86_64

Source code installation:

  1. Download the software
  • Firstly,In terminal window of Linux system, Navigate to the directory where you want to download the PostgreSQL source code.
  • Use ‘wget’ command to download the source code tar file for PostgreSQL v11.0.you can get the link from the official website:https://www.postgresql.org/ftp/source/ and select the version you want to install Here we install v11.0. Download the source code tar file for your platform and version.

[root@postgres1 ~]#wgethttps://ftp.postgresql.org/pub/source/v11.0/postgresql-11.0.tar.gz

  1. Extract the source code:

If you download the tar file, a directory named ‘postgresql-11.0.tar.gz’, you can extract it by running the command:

[root@postgres1 ~]# tar –xvf postgresql-11.0.tar.gz (untar the file).

After extracting thetar file, a directory named ‘postgresql-11.0’ will be created.

  1. Configure PostgreSQL:

Navigate into the extracted directory:

[root@postgres1 ~]# cd postgresql-11.0

[root@postgres1 postgresql-11.0]#

Now, the ‘configure’ command will check your system for dependencies and set up the build environment.

[root@postgres1 postgresql-11.0]# ./configure

  1. Build and install PostgreSQL:

Run the ‘make’ command will compile the source code into executable files.

[root@postgres1 postgresql-11.0]#make

Run the ‘make install’ command install PostgreSQL on your system.

[root@postgres1 postgresql-11.0]#make install

PostgreSQL installation complete.

  1. Initialize the database cluster:
  • Change directory to ‘pgsql’ by using command:

  • Now check the files in pgsql by using command

bin  include  lib  share

  • To check the directories run the following commands:

  • Change the directory to where you want to create PostgreSQL data directory

  • Now create a data directory for PostgreSQL, Here we create the directory ‘/u01/data’ by using following command:

  • Set the owner and group of the directory to the ‘postgres’ user:

  • Switch to the ‘postgres’ user by running this command:

This will change your user to ‘postgres’ and put you in the home directory of the user.

  • Run the ‘initdb’ command to initialize the PostgreSQL data directory and also used to create a cluster:

The files belonging to this database system will be owned by user “postgres”.

This user must also own the server process.

  1. Start the cluster

Start the PostgreSQL server using the ‘pg_ctl’ command:

This will start the PostgreSQL server with the data directory that was initialized in the previous step.

This command will verify cluster information i.e list of processes running on your system. If the PostgreSQL server is running, you should see a process with the name “postgres”.

Now connect to psql command-line interface, to run the sql commands and interact with the PostgreSQL server.

Author    : Prudhvi Teja

LinkedIn  : http://linkedin.com/in/prudhvi-teja-nagabhyru-715052224

Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates

KTExperts is always active on social media platforms.

Facebook  : https://www.facebook.com/ktexperts/
LinkedIn    : https://www.linkedin.com/company/ktexperts/
Twitter       : https://twitter.com/ktexpertsadmin
YouTube   :  https://www.youtube.com/c/ktexperts
Instagram  : https://www.instagram.com/knowledgesharingplatform

 

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add Comment