Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

PostgreSQL YUM installations (Fedora / Red Hat / CentOS / Scientific Linux)

Switch to root user.
$ su -
1.Finding out which distribution and architecture you are using
If you do not know which OS/arch you are using, please run the following:

Step 1: Find distribution
# cat /etc/redhat-release : This command will give you an output like: 
Red Hat Enterprise Linux Server release 7.3 (Maipo)
CentOS Linux release 7.3.1611 (Core)
CentOS release 6.9 (Final)
Fedora release 25 (Twenty Five)
or similar. So they mean you are using RHEL 7.3, CentOS 7.3, CentOS 6.9 or Fedora 25, respectively.
Step 2: Find architecture
# uname -m
# uname -m : This command will give you an output like x86_64, ppc4le or i686. 
So, if the first output is CentOS-6 and the second one is x86_64, go to Repository Packages page, and find the repository RPMs in the PostgreSQL version that you are looking for.

2.Go  to PostgreSQL Yum Repository
3.Select the version of PostgreSQL that you want to install and then your OS, version architecture then Download the RPM for your platform Following link
PostgreSQL publishes rpm packages for all Linux platforms, their packages are generally fresher than those in the other repository. We need to add the repository on our machine by installing repo rpm.
###  32 bit  ###
###  64 bit  ###
4.Install the RPM
rpm -ivh pgdg-redhat96-9.6-3.noarch.rpm
rpm -Uvh pgdg-redhat96-9.6-3.noarch.rpm
CentOS and Redhat repos contains the older version of PostgreSQL packages which will not be required any more, so just exclude the PostgreSQL packages by adding following line in proper sections.
5.Locate and edit your distributions .repo file, located:
On Fedora: /etc/yum.repos.d/fedora.repo and /etc/yum.repos.d/fedora-updates.repo, [fedora] sections
On CentOS: /etc/yum.repos.d/CentOS-Base.repo, [base] and [updates] sections
On Red Hat: /etc/yum/pluginconf.d/rhnplugin.conf [main] section

Example ( in CentOS /etc/yum.repos.d/CentOS-Base.repo, [base] section):
name=CentOS-$releasever - Base
6.Do a quick search which will show you available packages for postgres
yum list postgres*

7.Install Packages as per choice
yum install postgresql96 postgresql96-server postgresql96-libs postgresql96-contrib postgresql96-devel
8.Initialize the PostgreSQL.
# service postgresql-9.6 initdb

9.PostgreSQL normally listens on the localhosts only, if would you like to enable the PostgreSQL to listen on all ip addresses; edit the /var/lib/pgsql/9.1/data/postgresql.conf 
# vi /var/lib/pgsql/9.6/data/postgresql.conf
Go to Connections and Communications section, find the “listen_address” variable. Uncomment the “listen_addresses” and place “*” instead of “localhost”

Before editing:
#listen_addresses = "localhost"
After editing:
listen_addresses = "*"
10.Add your network to access database remotely; Edit /var/lib/pgsql/9.6/data/pg_hba.conf .
# vi /var/lib/pgsql/9.6/data/pg_hba.conf
Add the following line according to your network configuration with md5 password authentication (Enable remote access of database).
# Local networks 
host all all      xx.xx.xx.xx/xx md5
# Example
host all all md5
host    all     all        md5
11. Restart the Postgre
# service postgresql-9.6 restart
12.Confirm the PostgreSQL listening.
# netstat -ant | grep 5432 
tcp        0      0  *               LISTEN
tcp6       0      0 :::5432                 :::*                    LISTEN
13.Creating Database:

Login as postgres user.
# su -l postgres
create the database called “test”
-bash-4.2$ createdb test
Login into the database.
-bash-4.2$ psql test
Create a new user called “raj” to manage the databases.
Login with the superuser.
$ psql -h geekdbserver -d test -U raj
14.Installing pgAdmin:
The command line administration will be good for the people who has full experience on PostgreSQL, but for the beginner pgAdmin will be best option to manage the databases. Install it by issue the following command.
#  yum install pgadmin3_96
Start pgAdmin3.
# pgadmin3 or pgadmin3_96
Connect to the database server using pgAdmin.

Screen shot of the pgAdmin after connected to the PosrgreSQL server.
Now you can manage the databases through the GUI-administration console.

15.Control service

To control the database service, use:
for RHEL 5 and 6:
service <name> <command>
where <command> can be:
start : start the database
stop : stop the database
restart : stop/start the database; used to read changes to core configuration files
reload : reload pg_hba.conf file while keeping database running

E.g. to start version 9.6:
service postgresql-9.6 start
With RHEL 7.1+ and CentOS 7.1+, and Fedora 23+, systemd is introduced. Use this instead:
 systemctl enable postgresql-9.6.service
 systemctl start postgresql-9.6.service


Popular posts from this blog

PostgreSQL pgBadger

PostgreSQL Pgbadger Installation On Linux

How to configure Replication Manager (repmgr) ?

How To Schedule PostgreSQL Jobs using pgAgent on Linux plateform

Script to kill ALL IDLE Connection In postgreSQL