• Home
  • Services
    • DBA Support
    • DBA Consultancy Services
    • PostgreSQL Support
    • Website Maintenance
  • Courses

    About Courses

    • List Of Courses
    • Become an Instructor
    Greenplum Database

    Greenplum Database

    $2,000.00 $1,500.00
    Read More
  • Company
    • FAQs
    • About Us
    • Contact
  • Events
  • Portfolio
  • Blogs
    • Blog – RayaFeeL
    • Blog – PostgreSQL Support
    • Blog – PostgreSQL Migration
    • Blog – All DB’s
    • Blog – Linux
    • Blog – Medical Coding
      • Cart

        0

    Have any question?
    (+91)8838953252
    ITsupport@rayafeel.com
    RegisterLogin
    RayaFeeL
    • Home
    • Services
      • DBA Support
      • DBA Consultancy Services
      • PostgreSQL Support
      • Website Maintenance
    • Courses

      About Courses

      • List Of Courses
      • Become an Instructor
      Greenplum Database

      Greenplum Database

      $2,000.00 $1,500.00
      Read More
    • Company
      • FAQs
      • About Us
      • Contact
    • Events
    • Portfolio
    • Blogs
      • Blog – RayaFeeL
      • Blog – PostgreSQL Support
      • Blog – PostgreSQL Migration
      • Blog – All DB’s
      • Blog – Linux
      • Blog – Medical Coding
        • Cart

          0

      Blog

      • Home
      • Blog
      • Blog
      • Source code Installation PostgreSQL 11 Database

      Source code Installation PostgreSQL 11 Database

      • Posted by Nijamutheen J
      • Categories Blog
      • Date August 7, 2019
      • Comments 0 comment

      In this tutorial, we will show you how to install PostgreSQL by using source code on your local system for learning and practicing PostgreSQL.

      PostgreSQL was developed for UNIX-like platforms, however, it was designed to be portable. It means that PostgreSQL can also run on other platforms such as Mac OS X, Solaris, and Windows.

      Since version 8.0, PostgreSQL offers an installer for Windows systems that makes the installation process easier and faster. For development purpose, we will install PostgreSQL version 11.3  on Linux

      There are three steps to complete the PostgreSQL installation:

      1. Download the PostgreSQL source file .
      2. Configure the PostgreSQL  source code .
      3. Verify the postgres configuration .

      1. First install required prerequisites such as gcc, readline-devel and zlib-devel using package manager as shown.

      # yum install gcc zlib-devel readline-devel [On RHEL/CentOS]
      # apt install gcc zlib1g-dev libreadline6-dev [On Debian/Ubuntu]
      # Zypper in gcc zlib1g-dev libreadline6-dev [On SUSE Linux ]

      2. Download the source code tar file from the official postgres website using the following wget command directly on system.

      # wget https://ftp.postgresql.org/pub/source/v11.3/postgresql-11.3.tar.gz

      3. Use tar command to extract the downloaded tarball file. New directory named postgresql-11.3 will be created.

      # tar -xvzf postgresql-11.3.tar.gz
      
      # ll
      Sample Output
      total 26328
      drwxr-xr-x 2 nijam nijam 4096 Sep 21 2014 bin
      -rwxr-xr-x 1 nijam nijam 347 Nov 7 2017 init-user-db.sh
      drwxr-xr-x 6 nijam nijam 4096 May 7 04:59 postgresql-11.3
      -rw-r--r-- 1 nijam nijam 25868246 Jul 8 12:04 postgresql-11.3.tar.gz
      drwxr-xr-x 2 nijam nijam 4096 May 17 2017 public_html

      4. Next step for installation procedure is to configure the downloaded source code by choosing the options according to your needs.

      # cd postgresql-11.3
      # ls -l
      total 764
      -rw-r--r-- 1 nijam nijam 730 May 7 04:46 .dir-locals.el
      -rw-r--r-- 1 nijam nijam 1622 May 7 04:46 .gitattributes
      -rw-r--r-- 1 nijam nijam 504 May 7 04:46 .gitignore
      -rw-r--r-- 1 nijam nijam 1192 May 7 04:46 COPYRIGHT
      -rw-r--r-- 1 nijam nijam 3848 May 7 04:46 GNUmakefile.in
      -rw-r--r-- 1 nijam nijam 284 May 7 04:46 HISTORY
      -rw-r--r-- 1 nijam nijam 74257 May 7 04:59 INSTALL
      -rw-r--r-- 1 nijam nijam 1682 May 7 04:46 Makefile
      -rw-r--r-- 1 nijam nijam 1212 May 7 04:46 README
      -rw-r--r-- 1 nijam nijam 522 May 7 04:46 aclocal.m4
      drwxr-xr-x 2 nijam nijam 4096 May 7 04:58 config
      -rwxr-xr-x 1 nijam nijam 561752 May 7 04:46 configure
      -rw-r--r-- 1 nijam nijam 84451 May 7 04:46 configure.in
      drwxr-xr-x 56 nijam nijam 4096 May 7 04:58 contrib
      drwxr-xr-x 3 nijam nijam 4096 May 7 04:58 doc
      drwxr-xr-x 16 nijam nijam 4096 May 7 04:59 src
      
      Note : use ./configure --help to get help about various options.

      5. Now create a directory where you want to install postgres files and use prefix option with configure.

      # mkdir /opt/11.3/ 
      # ./configure --prefix=/opt/11.3/ (or) ./configure --prefix=/opt/11.3/ --without-readline
      # ./configure --prefix=/opt/11.3/ --without-readline --without-zlib

      Sample output 

      6. After configuring, next we will start to build postgreSQL using following make command.

      # make (or) # make world (additional modules (contrib), type instead PostgreSQL, contrib, and documentation
      # make install (or) # make install-world (if you want contribution extension)

      7. Postgresql 11 has been installed in “/opt/11.3/” directory. now create a postgres user and directory to be used as data directory for initializing database cluster. Owner of this data directory should be postgres user and permissions should be 700 and also set path for postgresql binaries for our ease.

      # useradd nijam
      # passwd nijam
      # mkdir -p /data_11.3/
      # chown -R nijam.nijam /data_11.3/

      8. Now initialize database using the following command as postgres user before using any postgres commands.

      # su nijam
      $ /opt/11.3/bin/initdb -D /data_11.3/ -U nijam

      Where -D is location for this database cluster or we can say it is data directory where we want to initialize database cluster, -U for database superuser name.

      For more info and options we can refer initdb –help.

      9. After initializing database, start the database cluster or if you need to change port or listen address for server, edit the postgresql.conf file in data directory of database server.

      $ /opt/11.3/bin/pg_ctl -D /data_11.3/ -l logfile start

       

      10. After starting database, verify the status of postgres server process by using following commands.

      $ ps -ef |grep -i postgres
      $ netstat -apn |grep -i 5420

      We can see that database cluster is running fine, and startup logs can be found at location specified with -l option while starting database cluster.

      11. Now connect to database cluster and create database by using following commands.

      $ psql -p 5420
      postgres=# \l --- to list all databases in cluster
      postgres=# \q --- to quit form postgres console

      12. Create the environment variable file then only you can able to access the postgres utility directly on home path without going to bin path.

      $ cat /home/nijam/.profile
      export PATH=/opt/11.3/bin:$PATH
      export PGHOME=/opt/11.3/
      export PGDATA=/data_11.3/
      export LD_LIBRARY_PATH=/opt/11.3/lib
      export PGDATABASE=nijam
      export PGUSER=nijam
      export PGPORT=5420
      export PGLOCALEDIR=/opt/11.3/share/locale
      export MANPATH=$MANPATH:/opt/11.3/share/man

       

      • Share:
      Admin bar avatar
      Nijamutheen J

      Nijamutheen J 7+ years of experience in PostgreSQL, Linux admin , web hosting - apache server , Oracle ,mySQL, Mriadb, vertica DB & Server security administrator

      My updated resume is https://www.tutorialdba.com/p/hi-i-have-4.html

      Previous post

      PostgreSQL 11 Installation - RPM
      August 7, 2019

      Next post

      PostgreSQL Installation types
      August 8, 2019

      Leave A Reply Cancel reply

      You must be logged in to post a comment.

      Login with:

      Login with Google Login with Twitter Login with LinkedIn Login with Microsoft


      Search

      ADVERTISEMENT

      Latest Posts

      PostgreSQL Patching version 9, 10,11
      10Oct2019
      Tools for PostgreSQL
      16Sep2019
      Postgres user creation and restrict DDL & database access
      13Sep2019
      PostgreSQL SSL Setup
      07Sep2019
      How to DELETE current XLOG / WAL LOG in postgresql database ?
      19Aug2019

      Latest Courses

      PostgreSQL Database

      PostgreSQL Database

      $600.00 $500.00
      Greenplum Database

      Greenplum Database

      $2,000.00 $1,500.00

      Preview Course

      Free

      Recent Forum Topics

      • thought behind whiteboard activity
      • Are you going to take your first ste
      • How to start working on an application?
      • please let me know pre requirements to increase work_mem
      • how to copy some data in one table to another table in postgres

      2ndquadrant.in

      (+91) 8838953252

      ITsupport@rayafeel.com

      Company

      • About Us
      • Contact
      • Our Team
      • Blog

      COURSES

      • List Of Course
      • Become An Instructor
      • Events
      • Postgres Support Blog

      Support

      • DBA Support
      • Consultancy Services
      • Postgres Migration Blogs
      • Forum

      Recommend

      • Groups
      • Login
      • FAQs
      • SignUp

      IT Services by rayafeel.com. Powered by Rayafeel Technologies Pvt Ltd.

      • Privacy
      • Terms

      Become An Instructor?

      Join thousand of instructors and earn money hassle free!

      Get Started Now

      Login with:

      Login with Google Login with Twitter Login with LinkedIn Login with Microsoft

      Login with your site account

      Lost your password?

      Not a member yet? Register now

      Register a new account

      Are you a member? Login now