PostgreSQL is one of the best relational database managers in the world. Its main virtue is to be a reliable rock. Today, I will show you how to install PostgreSQL 11 on CentOS 7.
In this site we have talked before about PostgreSQL, it is difficult not to do it when you have in front of a database manager as advanced and reliable as this one. Recently, version 11 of this fantastic software was released.
In this new version, it highlights the speed improvements in the processing of very large databases. Something sysadmin will surely appreciate.
On the other hand, PostgreSQL 11 adds the ability to partition data by a hash key. This translates into improved data robustness and security.
Install PostgreSQL 11 on CentOS 7
PostgreSQL 11 is a novelty. It is the first big release since October 2017. Many sysadmins will look for a way to update or install it from 0. The latter is the goal of this article.
1. Upgrade the system
First, you need to update the system. This in order to get the latest security patches available for the system. With this, you gain stability and robustness.
:~$ su :~# yum update
Now you can continue the installation.
2. Adding the PostgreSQL repository
Actually, PostgreSQL is available for many operating systems such as Debian, Ubuntu, or CentOS 7, but the version that comes in the official repositories of each distribution is usually obsolete and outdated.
In short, you need to resort to an external repository to perform the installation. Fortunately, PostgreSQL has one and it is very easy.
First, run this command as root user:
:~# yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
After that, the repository has been added.
You can also verify that.
:~# yum repolist
As you can see, the repository is added
3. Install PostgreSQL 11
Thanks to the repository, now, you can install the new version of PostgreSQL in an easy way. Just run this command:
:~# yum install postgresql11 postgresql11-server
After that, initialize the database:
:~# /usr/pgsql-11/bin/postgresql-11-setup initdb
Next, start and enable PostgreSQL service:
:~# systemctl enable postgresql-11 :~# systemctl start postgresql-11
This process must be done because of the security policies of CentOS. CentOS 7 installs the package but does not start the PostgreSQL service automatically.
Finally, check the service status.
:~# systemctl status postgresql-11
The installation has been successful
4. Using PostgreSQL 11
Before using PostgreSQL You must install sudo. You also have to add your current user to the sudoers file:
:~# yum install sudo
Then, open the file /etc/sudoers
and edit it. See the image for the guide. In “angelo” write your user.
:~# nano /etc/sudoers
Then, close session and access as postgres user.
:~# exit :~$ sudo -i -u postgres :~$ psql
postgres=# \l
Conclusion
PostgreSQL is a great database manager. Each time it improves more and more and aims to be the leading open source option in this area. This new version adds performance improvements and installing it in CentOS 7 is not a big complication compared to its benefits.
Please share this article on your social networks.