Skip to content

Installing and configuring PostgreSQL 9.3 and 9.4 on RHEL 7

Red Hat Enterprise Linux 7 was released recently. The day after the release, we announced PostgreSQL 9.4 RPMs for RHEL 7, and last week we pushed PostgreSQL 9.3 RPMs for RHEL 7.

Since Red Hat switched to systemd as of RHEL 7, there are some changes in the packaging as compared to RHEL 5 and RHEL 6. So, how do you install and configura PostgreSQL on RHEL 7?
First, as usual, you need to install the repository package. Please visit the repo RPMs page. You will see a link to the repo package links, like for 9.4 and 9.3.

So, to install 9.4 repo RPMs for RHEL 7, run:

yum install

to install 9.3 repo RPMs for RHEL 7, run:

yum install

Next step is installing RPMs. You can either install the individual RPMs, or use groupinstall feature that install -libs, -server, -contrib along with the client package.

To install PostgreSQL 9.4 on RHEL 7, please run

yum groupinstall "PostgreSQL Database Server 9.4 PGDG"

To install PostgreSQL 9.3 on RHEL 7, please run

yum groupinstall "PostgreSQL Database Server 9.3 PGDG"

The next step is initializing the cluster. This is done using a command line tool, which is designed for the RPMs. Please run this command as root.

For 9.4:

/usr/pgsql-9.4/bin/postgresql94-setup initdb

For 9.3:

/usr/pgsql-9.3/bin/postgresql93-setup initdb

If there is no error message, you are ready to start the cluster. This is done using the unit files:

For 9.4:

systemctl start postgresql-9.4.service

For 9.3:

systemctl start postgresql-9.3.service

The postmasters should start, if there is no port conflict, etc.

As of RHEL 7, as done in the Fedora packages for two years, the unit files are located under /lib/systemd/system/ directory. Please do not edit these files directly. Instead, if you want to make any changes, create a copy of them under /etc/systemd/system/ , and edit those files. Run
systemctl daemon-reload
after adding a custom unit file.

Also, as of RHEL 7, we got rid of the PGPORT variable in unit files. This will fix the issues caused by changing the port number both in init script / unit file and postgresql.conf. The port can now only be changed in postgresql.conf.

In order to start PostgreSQL on boot, you need to enable the unit file:

For 9.4:

systemctl enable postgresql-9.4.service

For 9.3:

systemctl enable postgresql-9.3.service

To restart or reload the instance, you can use the following commands:

For 9.4:

systemctl restart postgresql-9.4.service

systemctl reload postgresql-9.4.service

For 9.3:

systemctl restart postgresql-9.3.service

systemctl reload postgresql-9.3.service

Please let us know if you see any packaging issues.


No Trackbacks


Display comments as Linear | Threaded

No comments

The author does not allow comments to this entry

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.

Form options