Step 1:
[root@tutorialspots ~]# yum list postgresql* Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Determining fastest mirrors * base: mirror.sale-dedic.com * epel: mirror.yandex.ru * extras: mirror.sale-dedic.com * remi-safe: mirror.reconn.ru * updates: mirror.sale-dedic.com Available Packages postgresql.i686 9.2.23-3.el7_4 base postgresql.x86_64 9.2.23-3.el7_4 base postgresql-contrib.x86_64 9.2.23-3.el7_4 base postgresql-devel.i686 9.2.23-3.el7_4 base postgresql-devel.x86_64 9.2.23-3.el7_4 base postgresql-docs.x86_64 9.2.23-3.el7_4 base postgresql-jdbc.noarch 9.2.1002-5.el7 base postgresql-jdbc-javadoc.noarch 9.2.1002-5.el7 base postgresql-libs.i686 9.2.23-3.el7_4 base postgresql-libs.x86_64 9.2.23-3.el7_4 base postgresql-odbc.x86_64 09.03.0100-2.el7 base postgresql-pgpool-II.x86_64 3.4.6-1.el7 epel postgresql-pgpool-II-devel.x86_64 3.4.6-1.el7 epel postgresql-pgpool-II-extensions.x86_64 3.4.6-1.el7 epel postgresql-plperl.x86_64 9.2.23-3.el7_4 base postgresql-plpython.x86_64 9.2.23-3.el7_4 base postgresql-plruby.x86_64 0.5.3-13.el7 epel postgresql-plruby-doc.x86_64 0.5.3-13.el7 epel postgresql-pltcl.x86_64 9.2.23-3.el7_4 base postgresql-server.x86_64 9.2.23-3.el7_4 base postgresql-static.i686 9.2.23-3.el7_4 base postgresql-static.x86_64 9.2.23-3.el7_4 base postgresql-test.x86_64 9.2.23-3.el7_4 base postgresql-upgrade.x86_64 9.2.23-3.el7_4 base
Step 2:
[root@tutorialspots ~]# yum install postgresql-server Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast base | 3.6 kB 00:00 epel/x86_64/metalink | 29 kB 00:00 epel | 4.7 kB 00:00 extras | 3.4 kB 00:00 mariadb | 2.9 kB 00:00 nodesource | 2.5 kB 00:00 remi-safe | 2.9 kB 00:00 updates | 3.4 kB 00:00 vz-base | 951 B 00:00 vz-updates | 951 B 00:00 (1/6): epel/x86_64/group_gz | 88 kB 00:00 (2/6): extras/7/x86_64/primary_db | 146 kB 00:00 (3/6): epel/x86_64/updateinfo | 929 kB 00:00 (4/6): remi-safe/primary_db | 1.2 MB 00:01 (5/6): updates/7/x86_64/primary_db | 2.0 MB 00:01 (6/6): epel/x86_64/primary_db | 6.4 MB 00:02 Loading mirror speeds from cached hostfile * base: mirror.sale-dedic.com * epel: mirror.logol.ru * extras: mirror.sale-dedic.com * remi-safe: mirror.reconn.ru * updates: mirror.sale-dedic.com Resolving Dependencies --> Running transaction check ---> Package postgresql-server.x86_64 0:9.2.23-3.el7_4 will be installed --> Processing Dependency: postgresql-libs(x86-64) = 9.2.23-3.el7_4 for package: postgresql-server-9.2.23-3.el7_4.x86_64 --> Processing Dependency: postgresql(x86-64) = 9.2.23-3.el7_4 for package: post gresql-server-9.2.23-3.el7_4.x86_64 --> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-server-9. 2.23-3.el7_4.x86_64 --> Running transaction check ---> Package postgresql.x86_64 0:9.2.23-3.el7_4 will be installed ---> Package postgresql-libs.x86_64 0:9.2.23-3.el7_4 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: postgresql-server x86_64 9.2.23-3.el7_4 base 3.8 M Installing for dependencies: postgresql x86_64 9.2.23-3.el7_4 base 3.0 M postgresql-libs x86_64 9.2.23-3.el7_4 base 234 k Transaction Summary ================================================================================ Install 1 Package (+2 Dependent packages) Total download size: 7.0 M Installed size: 33 M Is this ok [y/d/N]: y Downloading packages: (1/3): postgresql-libs-9.2.23-3.el7_4.x86_64.rpm | 234 kB 00:00 (2/3): postgresql-9.2.23-3.el7_4.x86_64.rpm | 3.0 MB 00:01 (3/3): postgresql-server-9.2.23-3.el7_4.x86_64.rpm | 3.8 MB 00:01 -------------------------------------------------------------------------------- Total 4.3 MB/s | 7.0 MB 00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : postgresql-libs-9.2.23-3.el7_4.x86_64 1/3 Installing : postgresql-9.2.23-3.el7_4.x86_64 2/3 Installing : postgresql-server-9.2.23-3.el7_4.x86_64 3/3 Verifying : postgresql-9.2.23-3.el7_4.x86_64 1/3 Verifying : postgresql-server-9.2.23-3.el7_4.x86_64 2/3 Verifying : postgresql-libs-9.2.23-3.el7_4.x86_64 3/3 Installed: postgresql-server.x86_64 0:9.2.23-3.el7_4 Dependency Installed: postgresql.x86_64 0:9.2.23-3.el7_4 postgresql-libs.x86_64 0:9.2.23-3.el7_4 Complete!
Data Directory: /var/lib/pgsql/data
Step 3:
postgresql-setup initdb
[root@tutorialspots ~]# postgresql-setup initdb Initializing database ... OK
Step 4:
systemctl enable postgresql.service service postgresql start
[root@tutorialspots ~]# systemctl enable postgresql.service Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.serv ice to /usr/lib/systemd/system/postgresql.service. [root@tutorialspots ~]# service postgresql start Redirecting to /bin/systemctl start postgresql.service
Note:
You can install other version e.g: 11 by using this repo: https://download.postgresql.org/pub/repos/yum/testing/11/redhat/rhel-7-x86_64/pgdg-centos11-11-1.noarch.rpm
(You can choose your repo here)
[root@tutorialspots ~]# rpm -ivh https://download.postgresql.org/pub/repos/yum/testing/11/ redhat/rhel-7-x86_64/pgdg-centos11-11-1.noarch.rpm Retrieving https://download.postgresql.org/pub/repos/yum/testing/11/redhat/rhel- 7-x86_64/pgdg-centos11-11-1.noarch.rpm warning: /var/tmp/rpm-tmp.UOLTLP: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY Preparing... ################################# [100%] Updating / installing... 1:pgdg-centos11-11-1 ################################# [100%]
Now you can install:
yum install postgresql11-server