0% found this document useful (0 votes)
35 views10 pages

Installing PostgreSQL From A Yum Repository

The document discusses installing PostgreSQL from a Yum repository. It begins by explaining what a Linux repository is. It then provides steps to use the PostgreSQL repository from PostgreSQL.org, which involves downloading the required RPM, checking existing repos, installing the RPM, and initializing the data directory. Finally, it shows how to start the PostgreSQL service and verify the installation using psql.

Uploaded by

Stephen Efange
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views10 pages

Installing PostgreSQL From A Yum Repository

The document discusses installing PostgreSQL from a Yum repository. It begins by explaining what a Linux repository is. It then provides steps to use the PostgreSQL repository from PostgreSQL.org, which involves downloading the required RPM, checking existing repos, installing the RPM, and initializing the data directory. Finally, it shows how to start the PostgreSQL service and verify the installation using psql.

Uploaded by

Stephen Efange
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Installing PostgreSQL from a Yum Repository

Table of Contents
Overview.....................................................................................................................................................3
Using the PostgreSQL repository from PostgreSQL.org.............................................................................3
Overview

A Linux repository is a storage location from which your system retrieves and installs OS updates and
applications. Each repository is a collection of software hosted on a remote server and intended to be
used for installing and updating software packages on Linux systems. When you run commands such as
“sudo apt update” or “sudo apt upgrade”, you may be pulling package information and package updates
from a number of repositories.

By Sandra Henry-Stocker, Unix Dweeb, Network World, Sept 18 2018

https://www.networkworld.com/article/3305810/how-to-list-repositories-on-linux.html

Using the PostgreSQL repository from PostgreSQL.org

https://www.postgresql.org/download/linux/redhat/

Click on the repository link in red above.

It will take you to the website https://yum.postgresql.org/


Select the version of PostgreSQL you want to install. Let’s do 9.6, so click on 9.6 link above.

Now select the right repo for your OS distribution and version of Linux. I am Running Centos 7 on 64-bit
machine.
So click on

You can also just right click on the link and select properties to then get the link.

Use wget to download the required rpm.

cd /opt

wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-
latest.noarch.rpm

Take a look at the current repo files on your system before installing the rpm you just downloaded.

As root user on Linux: ls -l /etc/yum.repos.d/


Install the rpm

rpm -ivh pgdg-redhat-repo-latest.noarch.rpm

The name signifies that this rpm is provided by redhat.

Now there should be a new repo file that should have been created from the installation we just did.

Notice the repo file pgdg-redhat-all.repo that was not there before the installation.

This file is basically like an address book where the yum program can look in to get addresses of the
repositories it needs to look in to browse and download software.

Take a peek at the file with the less command

less /etc/yum.repos.d/pgdg-redhat-all.repo
Now search for and get ready to install version 9.6

yum list | grep -i postgres| grep -i 9.6

Install a few of the required rpm packages


yum install -y postgresql96.x86_64 postgresql96-libs.x86_64 postgresql96-contrib.x86_64 postgresql96-
server.x86_64

Now query the rpm server package and get the name of the data directories, service name etc.

rpm -ql postgresql96-server-9.6.15-1PGDG.rhel7.x86_64

now initialize the data directory /var/lib/pgsql/9.6/data

login as the posgres user

[root@mafiscotech01 opt]# su – postgres

Run the initdb script to populate the data directory

/usr/pgsql-9.6/bin/initdb -D /var/lib/pgsql/9.6/data
You can optionally start PostgreSQL server with

/usr/pgsql-9.6/bin/pg_ctl -D /var/lib/pgsql/9.6/data start

Or using the service name postgresql-9.6.service

service postgresql-9.6.service start

I had to key in my user sefange password

Check to see if the PostgreSQL server process or postmaster is up:

ps -ef | grep -i postgres


service postgresql-9.6.service status

Use the postgres command line client psql to log in

List the databases on the system with \l

Enable the service

systemctl enable postgresql-9.6.service

You might also like