Skip to content

Running more than one 9.4 /9.3 instance in parallel on RHEL 7

In the 3rd post of "PostgreSQL on RHEL7 series, I will mention about running more than one 9.4 instance on RHEL 7. This article is also valid for 9.3.
In previous versions of RHEL, a good way to start multiple instance is/was using sysconfig files. As of RHEL 7, this is pretty much simplified.

First, you will need to create a new unit file for the new cluster. You can give any name in here. To distinguish the cluster, I added port value to the unit file name:

cp /lib/systemd/system/postgresql-9.4.service /etc/systemd/system/postgresql-9.4-5434.service

Ok, now please edit this file, and change PGDATA. Please note that you can give any directory name in here that postgres can access. You don't have to create this directory now, it will be created in the next step:


Let's move forward with initdb:

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

As you probably noticed, we passed a string to setup script, as a second parameter. This one must match the name of the unit file you created in the previous step. This script will run initdb in the specifled location.

Final step before starting the cluster is changing the port number:

sed -i "s/#port = 5432/port = 5434/g" /var/lib/pgsql/9.4/data-5434/postgresql.conf

Now, you can start the cluster:

systemctl start postgresql-9.4-5434.service

Please don't forget to set this instance to start on boot:

systemctl enable postgresql-9.4-5434.service

You can check the status of the cluster with the following command:

systemctl status postgresql-9.4-5434.service
postgresql-9.4-5434.service - PostgreSQL 9.4 database server
Loaded: loaded (/etc/systemd/system/postgresql-9.4-5434.service; enabled)
Active: active (running) since Thu 2014-07-03 16:07:49 EEST; 7min ago
Process: 17245 ExecStart=/usr/pgsql-9.4/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS)
Process: 17240 ExecStartPre=/usr/pgsql-9.4/bin/postgresql94-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 17250 (postgres)
CGroup: /system.slice/postgresql-9.4-5434.service
├─17250 /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data-5434
├─17251 postgres: logger process
├─17253 postgres: checkpointer process
├─17254 postgres: writer process
├─17255 postgres: wal writer process
├─17256 postgres: autovacuum launcher process
└─17257 postgres: stats collector process

Jul 03 16:07:48 rhel-7-x86-64 pg_ctl[17245]: < 2014-07-03 16:07:48.490 EEST >LOG: redirecting log output to logging collector process
Jul 03 16:07:48 rhel-7-x86-64 pg_ctl[17245]: < 2014-07-03 16:07:48.490 EEST >HINT: Future log output will appear in directory "pg_log".
Jul 03 16:07:49 rhel-7-x86-64 systemd[1]: Started PostgreSQL 9.4 database server.
Jul 03 16:15:13 rhel-7-x86-64 systemd[1]: Started PostgreSQL 9.4 database server.


No Trackbacks


Display comments as Linear | Threaded

Jacquelin Lanzafame on :

I'm not sure why but this weblog is loading incredibly slow for me. Is anyone else having this issue or is it a problem on my end? I'll check back later and see if the problem still exists.

Al Peevey on :

Of course you're right. There's something about that, and that's a great idea. I support you.

Elmira Flanegan on :

Excellent read, I just passed this onto a friend who was doing some research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that: Thanks for lunch!

Gerry Demar on :

What’s Taking place i'm new to this, I stumbled upon this I've discovered It absolutely helpful and it has aided me out loads. I'm hoping to contribute & help other customers like its helped me. Great job.

Tisha Carnett on :

Good write-up, I’m normal visitor of one’s web site, maintain up the nice operate, and It is going to be a regular visitor for a lengthy time.

Anglea Millison on :

Hi! Someone in my Facebook group shared this website with us so I came to check it out. I'm definitely loving the information. I'm bookmarking and will be tweeting this to my followers! Fantastic blog and excellent design.

Wilson Zangara on :

Nice post. I was checking continuously this blog and I am impressed! Very useful info particularly the last part :-) I care for such info much. I was looking for this certain info for a long time. Thank you and best of luck.

Woodrow Feliberty on :

There are some interesting cut-off dates on this article but I don’t know if I see all of them heart to heart. There may be some validity but I'll take maintain opinion till I look into it further. Good article , thanks and we want more! Added to FeedBurner as effectively

Sandie Broman on :

You have hit the spot. There is something in this and I think this is a good idea. I agree with you.

Layne Kasson on :

Cool blog, many thanks for the contribution

Jinny Rav on :

My brother suggested I would possibly like this blog. He was entirely right. This post actually made my day. You can not imagine simply how so much time I had spent for this information! Thank you!

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