How to connect to specific postgres version through psql when both (9.0 and 9.2) are on the same port? It's on RedHat 4.1.2.
1 Answer
You can run two versions of PostgreSQL on the same port by having them bind to different IP addresses.
Assign multiple IP addresses to a network interface, or add an extra network interface. Say 10.1.1.2 and 10.1.1.3.
In your 9.1 install's postgresql.conf set your listen_addresses to one of the addresses; say 10.1.1.2. In the 9.3 install's postgresql.conf set listen_addresses to bind to 10.1.1.3. Restart both servers.
You might want to put 127.0.0.1 in the 9.3 server's listen_addresses so it binds to the local loopback address too. (Note that you can alias the loopback to add more IPs for the local host if you need to, e.g. 127.0.0.2).
If using separate IPs is not going to work for you, your only other option is to use a container that provides virtually isolated network stacks (like LXC), or use full virtualisation.