Posted at

How to install postgresql96 on CentOS 7.x


  • install yum repository for CentOS7.x

# yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm

Loaded plugins: fastestmirror, langpacks
pgdg-centos96-9.6-3.noarch.rpm | 4.7 kB 00:00:00
Examining /var/tmp/yum-root-H7b1MM/pgdg-centos96-9.6-3.noarch.rpm: pgdg-centos96-9.6-3.noarch
Marking /var/tmp/yum-root-H7b1MM/pgdg-centos96-9.6-3.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-centos96.noarch 0:9.6-3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================
Installing:
pgdg-centos96 noarch 9.6-3 /pgdg-centos96-9.6-3.noarch 2.7 k

Transaction Summary
==============================================================================================================================================================================
Install 1 Package

Total size: 2.7 k
Installed size: 2.7 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pgdg-centos96-9.6-3.noarch 1/1
Verifying : pgdg-centos96-9.6-3.noarch 1/1

Installed:
pgdg-centos96.noarch 0:9.6-3

Complete!


  • install postgresql96

# yum install postgresql96 postgresql96-contrib postgresql96-devel postgresql96-libs postgresql96-server

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.jaist.ac.jp
* elrepo: ftp.yz.yamagata-u.ac.jp
* epel: ftp.jaist.ac.jp
* epel-debuginfo: ftp.jaist.ac.jp
* epel-source: ftp.jaist.ac.jp
* extras: ftp.jaist.ac.jp
* updates: ftp.jaist.ac.jp
Resolving Dependencies
--> Running transaction check
---> Package postgresql96.x86_64 0:9.6.11-1PGDG.rhel7 will be installed
---> Package postgresql96-contrib.x86_64 0:9.6.11-1PGDG.rhel7 will be installed
---> Package postgresql96-devel.x86_64 0:9.6.11-1PGDG.rhel7 will be installed
---> Package postgresql96-libs.x86_64 0:9.6.11-1PGDG.rhel7 will be installed
---> Package postgresql96-server.x86_64 0:9.6.11-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================
Installing:
postgresql96 x86_64 9.6.11-1PGDG.rhel7 pgdg96 1.4 M
postgresql96-contrib x86_64 9.6.11-1PGDG.rhel7 pgdg96 569 k
postgresql96-devel x86_64 9.6.11-1PGDG.rhel7 pgdg96 1.8 M
postgresql96-libs x86_64 9.6.11-1PGDG.rhel7 pgdg96 318 k
postgresql96-server x86_64 9.6.11-1PGDG.rhel7 pgdg96 4.5 M

Transaction Summary
==============================================================================================================================================================================
Install 5 Packages

Total download size: 8.6 M
Installed size: 38 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): postgresql96-contrib-9.6.11-1PGDG.rhel7.x86_64.rpm | 569 kB 00:00:02
(2/5): postgresql96-9.6.11-1PGDG.rhel7.x86_64.rpm | 1.4 MB 00:00:02
(3/5): postgresql96-libs-9.6.11-1PGDG.rhel7.x86_64.rpm | 318 kB 00:00:00
(4/5): postgresql96-devel-9.6.11-1PGDG.rhel7.x86_64.rpm | 1.8 MB 00:00:00
(5/5): postgresql96-server-9.6.11-1PGDG.rhel7.x86_64.rpm | 4.5 MB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 3.0 MB/s | 8.6 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql96-libs-9.6.11-1PGDG.rhel7.x86_64 1/5
Installing : postgresql96-9.6.11-1PGDG.rhel7.x86_64 2/5
Installing : postgresql96-server-9.6.11-1PGDG.rhel7.x86_64 3/5
Installing : postgresql96-devel-9.6.11-1PGDG.rhel7.x86_64 4/5
Installing : postgresql96-contrib-9.6.11-1PGDG.rhel7.x86_64 5/5
Verifying : postgresql96-libs-9.6.11-1PGDG.rhel7.x86_64 1/5
Verifying : postgresql96-server-9.6.11-1PGDG.rhel7.x86_64 2/5
Verifying : postgresql96-9.6.11-1PGDG.rhel7.x86_64 3/5
Verifying : postgresql96-devel-9.6.11-1PGDG.rhel7.x86_64 4/5
Verifying : postgresql96-contrib-9.6.11-1PGDG.rhel7.x86_64 5/5

Installed:
postgresql96.x86_64 0:9.6.11-1PGDG.rhel7 postgresql96-contrib.x86_64 0:9.6.11-1PGDG.rhel7 postgresql96-devel.x86_64 0:9.6.11-1PGDG.rhel7
postgresql96-libs.x86_64 0:9.6.11-1PGDG.rhel7 postgresql96-server.x86_64 0:9.6.11-1PGDG.rhel7

Complete!


  • check postgres account id

# cat /etc/passwd

postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash


  • start and check its status

# systemctl start postgresql-9.6.service

# systemctl status postgresql-9.6.service
● postgresql-9.6.service - PostgreSQL 9.6 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.6.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2018-11-28 13:26:25 JST; 6s ago
Docs: https://www.postgresql.org/docs/9.6/static/
Process: 10937 ExecStartPre=/usr/pgsql-9.6/bin/postgresql96-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 10943 (postmaster)
Tasks: 7
CGroup: /system.slice/postgresql-9.6.service
├─10943 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/
├─10946 postgres: logger process
├─10948 postgres: checkpointer process
├─10949 postgres: writer process
├─10950 postgres: wal writer process
├─10951 postgres: autovacuum launcher process
└─10952 postgres: stats collector process

:smile: