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 http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-1.noarch.rpm


to install 9.3 repo RPMs for RHEL 7, run:

yum install http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-redhat93-9.3-1.noarch.rpm


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.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Martin Gudmundsson on :

Thanks Devrim.
Very clear and easy to follow instructions.
And happy to see the PORT variable removed. That has caused some confusion, at least for me.

It would be nice with a follow up article on how to manage several postgres instances on the same EL7 OS.
Any chance of seeing that?

//Martin

Devrim Gündüz on :

Hi Martin.

Sure. I can write it in a few days.

Regards, Devrim

Ma Krech on :

Hey there! Do you know if they make any plugins to protect against hackers? I'm kinda paranoid about losing everything I've worked hard on. Any recommendations?

Kareen Sharabi on :

I do believe all of the ideas you've offered on your post. They're very convincing and can certainly work. Still, the posts are very brief for beginners. May just you please lengthen them a bit from subsequent time? Thank you for the post.

Horacio Thoams on :

Greetings I am so glad I found your website, I really found you by accident, while I was looking on Askjeeve for something else, Regardless I am here now and would just like to say thanks a lot for a remarkable post and a all round entertaining blog (I also love the theme/design), I don’t have time to read through it all at the minute but I have bookmarked it and also included your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the excellent job.

Denis Subbotin on :

Did you make rpm package of postgis for rhel7?

Devrim Gündüz on :

Hi Denis,

No. There are missing dependencies that should come from EPEL. I am waiting for EPEL 7 to recover from beta.

Regards, Devrim

September Basket on :

I’m not that much of a online reader to be honest but your sites really nice, keep it up! I'll go ahead and bookmark your website to come back in the future. All the best

freight forwarders in Bhubaneswar on :

Youre so cool! I dont suppose Ive read anything like this before. So nice to find somebody with some original thoughts on this subject. realy thank you for starting this up. this website is something that is needed on the web, someone with a little originality. useful job for bringing something new to the internet!

Raphael Whitbeck on :

you might have a fantastic weblog here! would you wish to make some invite posts on my blog?

Blaine Broddy on :

An fascinating discussion is value comment. I feel that you must write extra on this topic, it might not be a taboo subject but typically persons are not enough to talk on such topics. To the next. Cheers

Dion Egan on :

Have you tried searching google.com?

Grover Fosdick on :

Hmm it appears like your blog ate my first comment (it was super long) so I guess I'll just sum it up what I submitted and say, I'm thoroughly enjoying your blog. I too am an aspiring blog writer but I'm still new to everything. Do you have any suggestions for novice blog writers? I'd genuinely appreciate it.

Teodoro Gulizio on :

I was more than happy to search out this web-site.I wanted to thanks in your time for this wonderful learn!! I definitely having fun with each little bit of it and I have you bookmarked to take a look at new stuff you blog post.

Alfonso Caryk on :

Today, I went to the beach front with my children. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is totally off topic but I had to tell someone!

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.
CAPTCHA

Form options