How To Install PostgreSQL 10 on CentOS7

To Install PostgreSQL 10 on CentOS7

PostgreSQL 10 Released. PostgreSQL is an open source object-relational, highly scalable, SQL-compliant database management system. PostgreSQL is developed at the University of California at Berkeley Computer Science Department. This tutorial covers the method to install  PostgreSQL 10 on CentOS 7. 


Installing PostgreSQL 10

First, make sure you n add Postgres Yum Repository by making use of the following command.

[root@linuxhelp ~]# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-1.noarch.rpm
Loaded plugins: fastestmirror, langpacks
pgdg-redhat10-10-1.noarch.rpm                                                                             | 4.5 kB  00:00:00     
Examining /var/tmp/yum-root-JTrcnL/pgdg-redhat10-10-1.noarch.rpm: pgdg-redhat10-10-1.noarch
Marking /var/tmp/yum-root-JTrcnL/pgdg-redhat10-10-1.noarch.rpm to be installed
Resolving Dependencies
-->  Running transaction check
--->  Package pgdg-redhat10.noarch 0:10-1 will be installed
-->  Finished Dependency Resolution
.
.
Installing : pgdg-redhat10-10-1.noarch                                                                                     1/1 
  Verifying  : pgdg-redhat10-10-1.noarch                                                                                     1/1 

Installed:
  pgdg-redhat10.noarch 0:10-1                                                                                                    

Complete!

 


Once it is done, you shall go on with the Installation of PostgreSQL 10 Server by making use of the following command. This installs Yum packet manager as well. 

[root@linuxhelp ~]# yum install postgresql10-server
Loaded plugins: fastestmirror, langpacks
pgdg10-updates-testing                                                                                    | 4.1 kB  00:00:00     
(1/2): pgdg10-updates-testing/7/x86_64/group_gz                                                           |  245 B  00:00:01     
(2/2): pgdg10-updates-testing/7/x86_64/primary_db                                                         | 156 kB  00:00:02     
Determining fastest mirrors
 * base: centos.mirror.net.in
 * extras: centos.mirror.snu.edu.in
 * updates: mirror.ehost.vn
Resolving Dependencies
-->  Running transaction check
--->  Package postgresql10-server.x86_64 0:10.2-1PGDG.rhel7 will be installed
-->  Processing Dependency: postgresql10-libs(x86-64) = 10.2-1PGDG.rhel7 for package: postgresql10-server-10.2-1PGDG.rhel7.x86_64
-->  Processing Dependency: postgresql10(x86-64) = 10.2-1PGDG.rhel7 for package: postgresql10-server-10.2-1PGDG.rhel7.x86_64
-->  Processing Dependency: libpq.so.5()(64bit) for package: postgresql10-server-10.2-1PGDG.rhel7.x86_64
-->  Running transaction check
--->  Package postgresql10.x86_64 0:10.2-1PGDG.rhel7 will be installed
--->  Package postgresql10-libs.x86_64 0:10.2-1PGDG.rhel7 will be installed
-->  Finished Dependency Resolution

.
.
Installed:
  postgresql10-server.x86_64 0:10.2-1PGDG.rhel7                                                                                  

Dependency Installed:
  postgresql10.x86_64 0:10.2-1PGDG.rhel7                       postgresql10-libs.x86_64 0:10.2-1PGDG.rhel7                      

Complete!

 

After installing PostgreSQL server, It’ s required to initialize it before using the first time.

[root@linuxhelp ~]# /usr/pgsql-10/bin/postgresql-10-setup initdb
Initializing database ... OK

 

Once it is done, you need to start and enable PostgreSQL server.

[root@linuxhelp ~]# systemctl start postgresql-10.service
[root@linuxhelp ~]# systemctl enable postgresql-10.service
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-10.service to /usr/lib/systemd/system/postgresql-10.service.

 


Once it is done, you need to log in to postfix to verify if that installation has been completed successfully.

[root@linuxhelp ~]# su - postgres -c " psql" 
psql (10.2)
Type " help"  for help.

postgres=# password postgres
Enter new password: 
Enter it again: 
postgres=#

With this, the method to install PostgreSQL 10 on CentOS7 comes to an end. 


 

FAQ
Q
What happened to the database dump feature in phpPgAdmin?
A
You need to configure phpPgAdmin (in the config.inc.php file) to point to the location of the pg_dump and pg_dumpall utilities on your server. Once you have done that, the database export feature will appear.
Q
How does PostgreSQL use CPU resources?
A
The PostgreSQL server is process-based (not threaded). Each database session connects to a single PostgreSQL operating system (OS) process. Multiple sessions are automatically spread across all available CPUs by the OS.
Q
How do I control connections from other hosts?
A
, PostgreSQL only allows connections from the local machine using Unix domain sockets or TCP/IP connections. Other machines will not be able to connect unless you modify listen_addresses in the postgresql.conf file, enable host-based authentication by modifying the $PGDATA/pg_hba.conf file, and restart.
Q
Why phpPgAdmin ask me to re-enter login information for every page I access?
A
You most certainly have a problem with your PHP sessions. Make sure:

your browser accept cookies if your session ID relies on them

PHP has write access to the path set in the parameter “session.save_path” of your php.ini
Q
How do I change the sort ordering of textual data in PostgreSQL?
A
PostgreSQL sorts textual data according to the ordering that is defined by the current locale, which is selected during initdb.