Installing and running two postgresql versions on different ports (or two instances of same server)
- by Andrius
I have postgresql 9.1 installed on my machine (Ubuntu). I need another postgresql server that would run next to the old one. Exact version does not matter, but I'm thinking of using 9.2 version. How could I properly install and run another postgresql version without screwing old one (like upgrading). So those versions would run independently on different ports. Old one on 5432 and new one on 5433 for example.
The reason I need this is for two OpenERP versions databases. If I run two OpenERP servers (with different versions) on single postgresql port, it crashes because new OpenERP version detects old versions database and tries to run it, but it crashes because it uses another schemes.
P.S or maybe I could just run same postgresql server on two ports?
Update
So far I tried this:
/usr/lib/postgresql/9.1/bin/pg_ctl initdb -D main2
It created new cluster. I changed port to 5433 in new clusters directory postgresql.conf file. Then ran this:
/usr/lib/postgresql/9.1/bin/pg_ctl -D main2 -l logfile start
I got response server starting. But when I tried to enter new cluster's template database with:
psql template1 -p 5433
I got this error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"?
Also now when I try to stop server with:
/usr/lib/postgresql/9.1/bin/pg_ctl -D main2 -l logfile start
I get this error:
pg_ctl: PID file "main2/postmaster.pid" does not exist
Is server running?
So I don't understand if server is running and what I'm missing here?
Update
Found what was wrong. Stupid me. I didn't notice that when I changed port in .conf file, that line was commented already. So actually I didn't change anything first time, but thought I did and it used default 5432 port.