Re: Run 2 versions of Postgresql on one machine?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Peter Alberer" <h9351252(at)obelix(dot)wu-wien(dot)ac(dot)at>
Cc: "'Wei Wang'" <ww220(at)cam(dot)ac(dot)uk>, pgsql-general(at)postgresql(dot)org
Subject: Re: Run 2 versions of Postgresql on one machine?
Date: 2004-02-06 17:04:49
Message-ID: 1172.1076087089@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Peter Alberer" <h9351252(at)obelix(dot)wu-wien(dot)ac(dot)at> writes:
> it is quite easy to have two different version of postgres running on
> one machine. You need 2 different directories for the data files and 2
> different ports for the 2 postmasters to listen.

> -first you prepare the data directories with initdb, you can use the -D
> parameter to give the location of the files.
> -then start the database (postmaster) with parameter -p PORTNUMBER.
> Default port is 5432 so your existing postmaster process will probably
> listen there. The new version should listen on another port. All of the
> other Postgres utilities (pgsql, createdb, ...) also need the -p
> PORTNUMBER info as well, so they can connect to the right postmaster
> process.

You will also need to make sure that the executables and library files
get installed into different places, else one version will overwrite the
other at install time. I am not sure how to do that with an RPM-based
installation, but it is quite easy if you are building from source:
just supply a --prefix option to "configure". Perhaps

./configure --prefix=/usr/local/pgsql735

to install everything under /usr/local/pgsql735 (executables in
/usr/local/pgsql735/bin, etc).

Another thing you can do when building from source is to give each
version a different default port number:

./configure --prefix=/usr/local/pgsql735 --with-pgport=5735

This is pretty handy because the created postmaster, psql, and other
utilities will automatically use the right port number for their
version, and you don't have to fool around with setting it as Peter
mentions above. All that you have to do is adjust your PATH to find
the psql you want to use at the moment.

BTW, there is nothing that says you need to install under /usr. If you
are just testing, it is perfectly possible to build, install, and create
the data directory in directories under your own home directory, and
then manually start the postmaster running as yourself. This wouldn't
be good when you want the postmaster auto-started at system boot, but
for a temporary testing setup it's cool --- you do not need root
privileges at all when doing it this way.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-02-06 17:08:16 Re: how can I select into an array?
Previous Message Christoffer Gurell 2004-02-06 17:04:22 retrieving parts of a resultset