Database Server

 

Table of Contents

Overview

This guide provides information on how to install PostgreSQL.

For information on the installation and tuning of the rest of the supported databases please refer to the links below:

For more information regarding performance tuning, you can check the following link: PostgreSQL

 

Prerequisites

In order to PostgreSQL software the following prerequisites should be in place.

  • Linux CentOS or RedHat Ent version 6 or 7
  • At least 16 GB memory
  • At least 100GB of disk space allocated to /var directory

Note that as of this writing the PostgreSQL version is 9.4.

 

Installation process

The following section includes a step by step guide to complete PostgreSQL installation.

Install PostgreSQL packages

Use the following commands to install the required packages:

First install the appropriate repository for the CentOS version

For RHEL7 / CentOS 7

 $ sudo rpm -Uvh https://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-3.noarch.rpm

For RHEL6 / CentOS 6

 $ sudo rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm

Use yum to install the PostgreSQL packages:

$ sudo yum install postgresql94-server postgresql94-contrib pgadmin3_94

 

Initialize the database for the first time, start PostgreSQL and set the service to automatically start when the server reboots:

For RHEL7 / CentOS 7

$ sudo /usr/pgsql-9.4/bin/postgresql94-setup initdb
$ sudo systemctl start postgresql-9.4.service
$ sudo systemctl enable postgresql-9.4.service

For RHEL6 / CentOS 6

$ sudo service postgresql-9.4 initdb
$ sudo service postgresql-9.4 start
$ sudo chkconfig postgresql-9.4 on

 

 

Recommended PostgreSQL configuration

This section provides some PostgreSQL configuration suggestions: 

The configuration file is located under directory: /var/lib/pgsql/9.4/data and it is called postgresql.conf

Edit the file and set the following parameters:

max_connections = 1000
max_prepared_transactions = 100
listen_addresses = '*'
shared_buffers = 4GB    #This is the maximum value otherwise set it
to 0.25% of the total RAM
effective_cache_size = 12GB         # effective_cache_size should be ~75%
of the RAM (if it's a dedicated server)
work_mem = 128MB
maintenance_work_mem = 4GB #see shared_buffers