ubuntu - Installing and running two postgresql versions on different ports (or two instances of same server)
2014-07
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.
I've installed postgresql 8.3 manually on ubuntu 10.10, using ./configure, make and make install.
It works perfect but when I try to connect it using psql I need to type following cmd,
psql --port --host localhost
, my question is, Is there a way that I can omit --host=localhost
paramter ??
Error Details when passing only port and not passing --host
parameter
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.5431"?
How about an alias for psql?
alias psql="psql --host localhost"
Alternatively you could set the PGHOST environment variable.
Um, that syntax isn't correct to start: there is nothing being passed to --port. Locally, I get the exact message:
% psql --port --host=localhost
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.0"?
Passing a port (and omitting the --host) should work:
% psql --port 5432
Welcome to psql 8.3.8, the PostgreSQL interactive terminal.
Defining PGDATA, PGHOME, and PGPORT should help with not having to pass arguments to psql.