Re: Run 2 versions of Postgresql on one machine? - Mailing list pgsql-general

From Tom Lane
Subject Re: Run 2 versions of Postgresql on one machine?
Date
Msg-id 1172.1076087089@sss.pgh.pa.us
Whole thread Raw
In response to Re: Run 2 versions of Postgresql on one machine?  ("Peter Alberer" <h9351252@obelix.wu-wien.ac.at>)
List pgsql-general
"Peter Alberer" <h9351252@obelix.wu-wien.ac.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

pgsql-general by date:

Previous
From: Franco Bruno Borghesi
Date:
Subject: Re: Getting table attributes
Next
From: Steve Atkins
Date:
Subject: Re: Getting table attributes