When it comes to perform the installation of the database engine Postgres SQL the link to download the software is: https://yum.postgresql.org/.
Also take a look at the documentation to check the prerequisite: https://www.postgresql.org/docs/manuals/
The installation is performed using the repository and in this post I will install the version 9.5 on the operating system Red Hat el7.x86_64.
So, let’s install the repository with the root user:
[root@techdatabasket ~]# yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm Loaded plugins: downloadkvmonly-background, ibm-check-lotus-updates, ibm-check-upgrade, ibm-check-xorg-updates, ibm-repository, langpacks, post-transaction-actions, refresh-packagekit, versionlock pgdg-redhat-repo-latest.noarch.rpm | 6.2 kB 00:00:00 Examining /var/tmp/yum-root-wCUG1b/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-8.noarch Marking /var/tmp/yum-root-wCUG1b/pgdg-redhat-repo-latest.noarch.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package pgdg-redhat-repo.noarch 0:42.0-8 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================================================ Installing: pgdg-redhat-repo noarch 42.0-8 /pgdg-redhat-repo-latest.noarch 11 k Transaction Summary ============================================================================================================================================================================================================ Install 1 Package Total size: 11 k Installed size: 11 k Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pgdg-redhat-repo-42.0-8.noarch 1/1 Verifying : pgdg-redhat-repo-42.0-8.noarch 1/1 Installed: pgdg-redhat-repo.noarch 0:42.0-8 Complete!
Search for the installed repository using the command “yum search postgresql9”:
[root@techdatabasket ~]# yum search postgresql9 Loaded plugins: downloadkvmonly-background, ibm-check-lotus-updates, ibm-check-upgrade, ibm-check-xorg-updates, ibm-repository, langpacks, post-transaction-actions, refresh-packagekit, versionlock pgdg10 | 3.6 kB 00:00:00 pgdg11 | 3.6 kB 00:00:00 pgdg12 | 3.6 kB 00:00:00 pgdg94 | 3.6 kB 00:00:00 pgdg95 | 3.6 kB 00:00:00 pgdg96 | 3.6 kB 00:00:00 (1/12): pgdg11/7Workstation/x86_64/group_gz | 245 B 00:00:00 (2/12): pgdg12/7Workstation/x86_64/primary_db | 193 kB 00:00:00 (3/12): pgdg12/7Workstation/x86_64/group_gz | 245 B 00:00:00 (4/12): pgdg94/7Workstation/x86_64/group_gz | 247 B 00:00:00 (5/12): pgdg95/7Workstation/x86_64/group_gz | 249 B 00:00:00 (6/12): pgdg94/7Workstation/x86_64/primary_db | 399 kB 00:00:00 (7/12): pgdg95/7Workstation/x86_64/primary_db | 439 kB 00:00:00 (8/12): pgdg96/7Workstation/x86_64/group_gz | 249 B 00:00:00 (9/12): pgdg96/7Workstation/x86_64/primary_db | 399 kB 00:00:00 (10/12): pgdg10/7Workstation/x86_64/group_gz | 245 B 00:00:01 (11/12): pgdg10/7Workstation/x86_64/primary_db | 386 kB 00:00:02 (12/12): pgdg11/7Workstation/x86_64/primary_db | 356 kB 00:00:03 ========================================================================================= N/S matched: postgresql9 ========================================================================================= postgresql94-debuginfo.x86_64 : Debug information for package postgresql94 postgresql94-jdbc-javadoc.noarch : API docs for postgresql94-jdbc postgresql94-odbc-debuginfo.x86_64 : Debug information for package postgresql94-odbc postgresql94-tcl-debuginfo.x86_64 : Debug information for package postgresql94-tcl postgresql95-debuginfo.x86_64 : Debug information for package postgresql95 postgresql95-odbc-debuginfo.x86_64 : Debug information for package postgresql95-odbc postgresql95-tcl-debuginfo.x86_64 : Debug information for package postgresql95-tcl postgresql94.x86_64 : PostgreSQL client programs and libraries postgresql94-contrib.x86_64 : Contributed source and binaries distributed with PostgreSQL postgresql94-devel.x86_64 : PostgreSQL development header files and libraries postgresql94-docs.x86_64 : Extra documentation for PostgreSQL postgresql94-jdbc.noarch : JDBC driver for PostgreSQL postgresql94-libs.x86_64 : The shared libraries required for any PostgreSQL clients postgresql94-odbc.x86_64 : PostgreSQL ODBC driver postgresql94-plperl.x86_64 : The Perl procedural language for PostgreSQL postgresql94-plpython.x86_64 : The Python procedural language for PostgreSQL postgresql94-pltcl.x86_64 : The Tcl procedural language for PostgreSQL postgresql94-server.x86_64 : The programs needed to create and run a PostgreSQL server postgresql94-tcl.x86_64 : A Tcl client library for PostgreSQL postgresql94-test.x86_64 : The test suite distributed with PostgreSQL postgresql95.x86_64 : PostgreSQL client programs and libraries postgresql95-contrib.x86_64 : Contributed source and binaries distributed with PostgreSQL postgresql95-devel.x86_64 : PostgreSQL development header files and libraries postgresql95-docs.x86_64 : Extra documentation for PostgreSQL postgresql95-libs.x86_64 : The shared libraries required for any PostgreSQL clients postgresql95-odbc.x86_64 : PostgreSQL ODBC driver postgresql95-plperl.x86_64 : The Perl procedural language for PostgreSQL postgresql95-plpython.x86_64 : The Python procedural language for PostgreSQL postgresql95-plpython3.x86_64 : The Python3 procedural language for PostgreSQL postgresql95-pltcl.x86_64 : The Tcl procedural language for PostgreSQL postgresql95-server.x86_64 : The programs needed to create and run a PostgreSQL server postgresql95-tcl.x86_64 : A Tcl client library for PostgreSQL postgresql95-test.x86_64 : The test suite distributed with PostgreSQL postgresql96.x86_64 : PostgreSQL client programs and libraries postgresql96-contrib.x86_64 : Contributed source and binaries distributed with PostgreSQL postgresql96-devel.x86_64 : PostgreSQL development header files and libraries postgresql96-docs.x86_64 : Extra documentation for PostgreSQL postgresql96-libs.x86_64 : The shared libraries required for any PostgreSQL clients postgresql96-odbc.x86_64 : PostgreSQL ODBC driver postgresql96-plperl.x86_64 : The Perl procedural language for PostgreSQL postgresql96-plpython.x86_64 : The Python procedural language for PostgreSQL postgresql96-plpython3.x86_64 : The Python3 procedural language for PostgreSQL postgresql96-pltcl.x86_64 : The Tcl procedural language for PostgreSQL postgresql96-server.x86_64 : The programs needed to create and run a PostgreSQL server postgresql96-tcl.x86_64 : A Tcl client library for PostgreSQL postgresql96-test.x86_64 : The test suite distributed with PostgreSQL
After we have confirmed the installation of the repository, we can proceed with the installation using the command “yum install postgresql95 postgresql95-contrib postgresql95-server” :
[root@techdatabasket ~]# yum install postgresql95 postgresql95-contrib postgresql95-server Loaded plugins: downloadkvmonly-background, ibm-check-lotus-updates, ibm-check-upgrade, ibm-check-xorg-updates, ibm-repository, langpacks, post-transaction-actions, refresh-packagekit, versionlock Resolving Dependencies --> Running transaction check ---> Package postgresql95.x86_64 0:9.5.21-1PGDG.rhel7 will be installed --> Processing Dependency: postgresql95-libs(x86-64) = 9.5.21-1PGDG.rhel7 for package: postgresql95-9.5.21-1PGDG.rhel7.x86_64 ---> Package postgresql95-contrib.x86_64 0:9.5.21-1PGDG.rhel7 will be installed ---> Package postgresql95-server.x86_64 0:9.5.21-1PGDG.rhel7 will be installed --> Running transaction check ---> Package postgresql95-libs.x86_64 0:9.5.21-1PGDG.rhel7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================================================ Installing: postgresql95 x86_64 9.5.21-1PGDG.rhel7 pgdg95 1.3 M postgresql95-contrib x86_64 9.5.21-1PGDG.rhel7 pgdg95 540 k postgresql95-server x86_64 9.5.21-1PGDG.rhel7 pgdg95 4.1 M Installing for dependencies: postgresql95-libs x86_64 9.5.21-1PGDG.rhel7 pgdg95 225 k Transaction Summary ============================================================================================================================================================================================================ Install 3 Packages (+1 Dependent package) Total download size: 6.2 M Installed size: 26 M Is this ok [y/d/N]: y Downloading packages: warning: /var/cache/yum/x86_64/7Workstation/pgdg95/packages/postgresql95-9.5.21-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY ] 0.0 B/s | 960 kB --:--:-- ETA Public key for postgresql95-9.5.21-1PGDG.rhel7.x86_64.rpm is not installed (1/4): postgresql95-9.5.21-1PGDG.rhel7.x86_64.rpm | 1.3 MB 00:00:01 (2/4): postgresql95-libs-9.5.21-1PGDG.rhel7.x86_64.rpm | 225 kB 00:00:00 (3/4): postgresql95-contrib-9.5.21-1PGDG.rhel7.x86_64.rpm | 540 kB 00:00:01 (4/4): postgresql95-server-9.5.21-1PGDG.rhel7.x86_64.rpm | 4.1 MB 00:00:02 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 1.8 MB/s | 6.2 MB 00:00:03 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project <pgsqlrpms-hackers@pgfoundry.org>" Fingerprint: 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8 Package : pgdg-redhat-repo-42.0-8.noarch (@/pgdg-redhat-repo-latest.noarch) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : postgresql95-libs-9.5.21-1PGDG.rhel7.x86_64 1/4 Installing : postgresql95-9.5.21-1PGDG.rhel7.x86_64 2/4 failed to link /usr/bin/psql -> /etc/alternatives/pgsql-psql: /usr/bin/psql exists and it is not a symlink failed to link /usr/bin/clusterdb -> /etc/alternatives/pgsql-clusterdb: /usr/bin/clusterdb exists and it is not a symlink failed to link /usr/bin/createdb -> /etc/alternatives/pgsql-createdb: /usr/bin/createdb exists and it is not a symlink failed to link /usr/bin/createlang -> /etc/alternatives/pgsql-createlang: /usr/bin/createlang exists and it is not a symlink failed to link /usr/bin/createuser -> /etc/alternatives/pgsql-createuser: /usr/bin/createuser exists and it is not a symlink failed to link /usr/bin/dropdb -> /etc/alternatives/pgsql-dropdb: /usr/bin/dropdb exists and it is not a symlink failed to link /usr/bin/droplang -> /etc/alternatives/pgsql-droplang: /usr/bin/droplang exists and it is not a symlink failed to link /usr/bin/dropuser -> /etc/alternatives/pgsql-dropuser: /usr/bin/dropuser exists and it is not a symlink failed to link /usr/bin/pg_basebackup -> /etc/alternatives/pgsql-pg_basebackup: /usr/bin/pg_basebackup exists and it is not a symlink failed to link /usr/bin/pg_dump -> /etc/alternatives/pgsql-pg_dump: /usr/bin/pg_dump exists and it is not a symlink failed to link /usr/bin/pg_dumpall -> /etc/alternatives/pgsql-pg_dumpall: /usr/bin/pg_dumpall exists and it is not a symlink failed to link /usr/bin/pg_restore -> /etc/alternatives/pgsql-pg_restore: /usr/bin/pg_restore exists and it is not a symlink failed to link /usr/bin/reindexdb -> /etc/alternatives/pgsql-reindexdb: /usr/bin/reindexdb exists and it is not a symlink failed to link /usr/bin/vacuumdb -> /etc/alternatives/pgsql-vacuumdb: /usr/bin/vacuumdb exists and it is not a symlink Installing : postgresql95-contrib-9.5.21-1PGDG.rhel7.x86_64 3/4 Installing : postgresql95-server-9.5.21-1PGDG.rhel7.x86_64 4/4 Verifying : postgresql95-9.5.21-1PGDG.rhel7.x86_64 1/4 Verifying : postgresql95-libs-9.5.21-1PGDG.rhel7.x86_64 2/4 Verifying : postgresql95-contrib-9.5.21-1PGDG.rhel7.x86_64 3/4 Verifying : postgresql95-server-9.5.21-1PGDG.rhel7.x86_64 4/4 Installed: postgresql95.x86_64 0:9.5.21-1PGDG.rhel7 postgresql95-contrib.x86_64 0:9.5.21-1PGDG.rhel7 postgresql95-server.x86_64 0:9.5.21-1PGDG.rhel7 Dependency Installed: postgresql95-libs.x86_64 0:9.5.21-1PGDG.rhel7 Complete!
You can confirm the installation of the Postgres SQL version 9 by taking a look if some packages were installed:
[root@techdatabasket ~]# rpm -qa |grep postgres postgresql-server-9.2.24-2.el7_7.x86_64 postgresql95-contrib-9.5.21-1PGDG.rhel7.x86_64 postgresql-9.2.24-2.el7_7.x86_64 postgresql95-server-9.5.21-1PGDG.rhel7.x86_64 postgresql95-libs-9.5.21-1PGDG.rhel7.x86_64 postgresql-libs-9.2.24-2.el7_7.x86_64 postgresql95-9.5.21-1PGDG.rhel7.x86_64 [root@techdatabasket ~]#
You can also check the utilities:
[root@techdatabasket ~]# ls -ltr /usr/pgsql-9.5/bin total 8884 -rwxr-xr-x. 1 root root 9427 Feb 11 23:14 postgresql95-setup -rwxr-xr-x. 1 root root 2183 Feb 11 23:14 postgresql95-check-db-dir -rwxr-xr-x. 1 root root 24424 Feb 11 23:16 vacuumlo -rwxr-xr-x. 1 root root 71440 Feb 11 23:16 vacuumdb -rwxr-xr-x. 1 root root 63088 Feb 11 23:16 reindexdb -rwxr-xr-x. 1 root root 515472 Feb 11 23:16 psql -rwxr-xr-x. 1 root root 6286824 Feb 11 23:16 postgres -rwxr-xr-x. 1 root root 71000 Feb 11 23:16 pg_xlogdump -rwxr-xr-x. 1 root root 100824 Feb 11 23:16 pg_upgrade -rwxr-xr-x. 1 root root 16088 Feb 11 23:16 pg_test_timing -rwxr-xr-x. 1 root root 20416 Feb 11 23:16 pg_test_fsync -rwxr-xr-x. 1 root root 24408 Feb 11 23:16 pg_standby -rwxr-xr-x. 1 root root 79672 Feb 11 23:16 pg_rewind -rwxr-xr-x. 1 root root 151136 Feb 11 23:16 pg_restore -rwxr-xr-x. 1 root root 49464 Feb 11 23:16 pg_resetxlog -rwxr-xr-x. 1 root root 54896 Feb 11 23:16 pg_recvlogical -rwxr-xr-x. 1 root root 54712 Feb 11 23:16 pg_receivexlog -rwxr-xr-x. 1 root root 58624 Feb 11 23:16 pg_isready -rwxr-xr-x. 1 root root 84064 Feb 11 23:16 pg_dumpall -rwxr-xr-x. 1 root root 363472 Feb 11 23:16 pg_dump -rwxr-xr-x. 1 root root 41744 Feb 11 23:16 pg_ctl -rwxr-xr-x. 1 root root 41072 Feb 11 23:16 pg_controldata -rwxr-xr-x. 1 root root 32960 Feb 11 23:16 pg_config -rwxr-xr-x. 1 root root 75952 Feb 11 23:16 pgbench -rwxr-xr-x. 1 root root 75928 Feb 11 23:16 pg_basebackup -rwxr-xr-x. 1 root root 20160 Feb 11 23:16 pg_archivecleanup -rwxr-xr-x. 1 root root 28736 Feb 11 23:16 oid2name -rwxr-xr-x. 1 root root 105704 Feb 11 23:16 initdb -rwxr-xr-x. 1 root root 58680 Feb 11 23:16 dropuser -rwxr-xr-x. 1 root root 96168 Feb 11 23:16 droplang -rwxr-xr-x. 1 root root 58704 Feb 11 23:16 dropdb -rwxr-xr-x. 1 root root 67480 Feb 11 23:16 createuser -rwxr-xr-x. 1 root root 96168 Feb 11 23:16 createlang -rwxr-xr-x. 1 root root 63008 Feb 11 23:16 createdb -rwxr-xr-x. 1 root root 62960 Feb 11 23:16 clusterdb lrwxrwxrwx. 1 root root 8 Mar 18 16:30 postmaster -> postgres
Now you have your PostgreSQL version 9.5 installed 🙂
Hi! I am Bruno, a Brazilian born and bred, and I am also a naturalized Swedish citizen. I am a former Oracle ACE and, to keep up with academic research, I am a Computer Scientist with an MSc in Data Science and another MSc in Software Engineering. I have over ten years of experience working with companies such as IBM, Epico Tech, and Playtech across three different countries (Brazil, Hungary, and Sweden), and I have joined projects remotely in many others. I am super excited to share my interests in Databases, Cybersecurity, Cloud, Data Science, Data Engineering, Big Data, AI, Programming, Software Engineering, and data in general.
(Continue reading)