We currently have a PostgreSQL 11 Server which is about to be upgraded to version 15. There is a test box running Fedora 37. I’d like to try out several scripts on top of these different versions and for that purpose, so I tried to install both versions 11 and 15 and dnf did the job.
Where should I put postgresql.conf and pg_hba.conf to be able to specify the settings for different versions (instances). I anyway must define different listening port. I’m struggling to find instructions on internet.
Is this possible at all? Generelly, this is like running two DB Server instances on same box, but in my case, the versions are different.
Regards all!
2
Answers
Thanks to several answers and comments to my question and also some further investigation, the setup finally works as desired.
Before taking any action, the situation was as following:
This is the procedure applied to get desired setup:
And here, it came with error message: "...matches were filtered out by modular filtering for argument...". I'll cut it short, it got solved by following command (I don't know why exactly, but it worked):
This time, this worked:
initdb -D <folder>
but I ended up in a trouble in one of following steps. This is the way it worked on my server:postgresql.conf
files, example withvim
editor.If you're not sure where the files are, you can find them like this:
find / -iname 'postgresql.conf'
. I added "listen to all" and changed port. The port is mandatory to be changed, otherwise, second instance trying to address same port will fail to start.Make sure to remove comment prefix "#". For PG11, I used 54311 as shown, for PG15 I used 54315. Just make sure these are different and don't collide with other standard ports.
You need to repeat this, but connect to the other port
-p 54315
. Don't forget to allow acces in thepg_hba.conf
file. Here is an example for version 11:Don't forget to restart the PG server(s) or just reboot at all. Have fun!
This is very simple. If you use the PGDG packages from the PostgreSQL site, you can install the software for different PostgreSQL versions side by side. You have to create data directories for both instances using the
initdb
executable from the respective version. Configuration files likepostgresql.conf
andpg_hba.conf
will be in the respective data directories. All you have to do is to configure both instances to use a differentport
, otherwise you cannot start both at the same time.