Thread: Run 2 versions of Postgresql on one machine?

Run 2 versions of Postgresql on one machine?

From
"Wei Wang"
Date:
hi,

I just took over a project done by somebody else of some C extension of
Postgresql 7.1.3. And now I have to port it to pl/pgsql. The guy who
developed it said he didn't get it running under 7.2 for some reason. And I
suspect it might not run properly under 7.4.1. Since I only have one machine
so I really hope that I could run 7.1.3 and 7.4.1 on the same machine and
run his code on 7.1.3 while developing pl/pgsql on 7.4.1. Now can anyone
give a hand on whether this can be done, and if so, can you give me a little
direction on how to do this?


Many thanks,

Wei


Re: Run 2 versions of Postgresql on one machine?

From
"Peter Alberer"
Date:
Hi wei,

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.

Hope that helps,

peter

ps: if you install from the Postgres source, you can specify a new
default port number for your installation via a ./configure switch.


Re: Run 2 versions of Postgresql on one machine?

From
Richard Huxton
Date:
On Friday 06 February 2004 15:01, Wei Wang wrote:
> hi,
>
> I just took over a project done by somebody else of some C extension of
> Postgresql 7.1.3. And now I have to port it to pl/pgsql. The guy who
> developed it said he didn't get it running under 7.2 for some reason. And I
> suspect it might not run properly under 7.4.1. Since I only have one
> machine so I really hope that I could run 7.1.3 and 7.4.1 on the same
> machine and run his code on 7.1.3 while developing pl/pgsql on 7.4.1. Now
> can anyone give a hand on whether this can be done, and if so, can you give
> me a little direction on how to do this?

Build both from source.
Set the install directories for each differently (/usr/local/pg713/ or
something)
Set the ports for both differently (can't both use 5432 at the same time)
Initialise both to use different PGDATA directories
Alter startup scripts to start both separately, or start them manually.

That should do it - worth checking the archives since other people have done
this.
Hmm - do a search for Debian on the list archives (-hackers list IIRC) too. I
think the new packaging scheme there does the above out of the box - you
could just copy what it does.

--
  Richard Huxton
  Archonet Ltd

Re: Run 2 versions of Postgresql on one machine?

From
Tom Lane
Date:
"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

Re: Run 2 versions of Postgresql on one machine?

From
"Wei Wang"
Date:
Thank you all for your kind help. I have set up 7.4.1 and it's up and
running perfectly.
One small question that might not belong in this mailing list:
Since all the binary commands share the same name, e.g. initdb, createdb,
psql, etc, and the
default path is already the 7.1.3 version. How do I come up a way to access
binary commands of
both versions quickly without adding absolute path infront of those of
7.4.1?


Many thanks,

Wei

----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Peter Alberer" <h9351252@obelix.wu-wien.ac.at>
Cc: "'Wei Wang'" <ww220@cam.ac.uk>; <pgsql-general@postgresql.org>
Sent: Friday, February 06, 2004 5:04 PM
Subject: Re: [GENERAL] Run 2 versions of Postgresql on one machine?


> "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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html


Re: Run 2 versions of Postgresql on one machine?

From
"Joshua D. Drake"
Date:
Wei Wang wrote:
> Thank you all for your kind help. I have set up 7.4.1 and it's up and
> running perfectly.
> One small question that might not belong in this mailing list:
> Since all the binary commands share the same name, e.g. initdb, createdb,
> psql, etc, and the
> default path is already the 7.1.3 version. How do I come up a way to access
> binary commands of
> both versions quickly without adding absolute path infront of those of
> 7.4.1?
>

Well if you are using 7.4.1 primarily you can just change the path order
so that the pgsql/bin for 7.4.1 comes
before the pgsql/bin for 7.1.3. If not, you could set up some aliases...
if you are using bash:

alias psql74 = '/usr/local/pgsql74/bin/psql'




>
> Many thanks,
>
> Wei
>
> ----- Original Message -----
> From: "Tom Lane" <tgl@sss.pgh.pa.us>
> To: "Peter Alberer" <h9351252@obelix.wu-wien.ac.at>
> Cc: "'Wei Wang'" <ww220@cam.ac.uk>; <pgsql-general@postgresql.org>
> Sent: Friday, February 06, 2004 5:04 PM
> Subject: Re: [GENERAL] Run 2 versions of Postgresql on one machine?
>
>
>
>>"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
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 5: Have you checked our extensive FAQ?
>>
>>               http://www.postgresql.org/docs/faqs/FAQ.html
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match


--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL

Re: Run 2 versions of Postgresql on one machine?

From
Richard Huxton
Date:
On Friday 06 February 2004 18:21, Wei Wang wrote:
> Thank you all for your kind help. I have set up 7.4.1 and it's up and
> running perfectly.
> One small question that might not belong in this mailing list:
> Since all the binary commands share the same name, e.g. initdb, createdb,
> psql, etc, and the
> default path is already the 7.1.3 version. How do I come up a way to access
> binary commands of
> both versions quickly without adding absolute path infront of those of
> 7.4.1?

Make symlinks to the relevant version, so:

ln -s /usr/local/pg741/bin/psql psql741

Then you can call psql741 (although be careful with any environment
settings)..

If you don't like that, write a 2-line shell script to call the right one for
you.
--
  Richard Huxton
  Archonet Ltd

Re: Run 2 versions of Postgresql on one machine?

From
Mike Mascari
Date:
Joshua D. Drake wrote:

>Wei Wang wrote:
>
>
>>Thank you all for your kind help. I have set up 7.4.1 and it's up and
>>running perfectly.
>>One small question that might not belong in this mailing list:
>>Since all the binary commands share the same name, e.g. initdb, createdb,
>>psql, etc, and the
>>default path is already the 7.1.3 version. How do I come up a way to access
>>binary commands of
>>both versions quickly without adding absolute path infront of those of
>>7.4.1?
>>
>>
>Well if you are using 7.4.1 primarily you can just change the path order
>so that the pgsql/bin for 7.4.1 comes
>before the pgsql/bin for 7.1.3. If not, you could set up some aliases...
>if you are using bash:
>
>alias psql74 = '/usr/local/pgsql74/bin/psql'
>
>
gcc's configure has a --program-prefix and a --program-suffix option so:

./configure --program-suffix=-3.4

would generate the binary:

gcc-3.4

instead of:

gcc

I wonder if people would find that useful for PostgreSQL? It doesn't
seem to be a particularly hot topic, though.

Mike Mascari






Re: Run 2 versions of Postgresql on one machine?

From
"Joshua D. Drake"
Date:
>>
> gcc's configure has a --program-prefix and a --program-suffix option so:
>
> ./configure --program-suffix=-3.4
>
> would generate the binary:
>
> gcc-3.4
>
> instead of:
>
> gcc
>
> I wonder if people would find that useful for PostgreSQL? It doesn't
> seem to be a particularly hot topic, though.
>

Hah! I didn't even know you could do that... That could definately help
in some situations.

J



> Mike Mascari
>
>
>
>


--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL

Re: Run 2 versions of Postgresql on one machine?

From
"scott.marlowe"
Date:
I just set up two different accounts, one named pg73, one named pg74, for
instance, and run everything from there.  This also lets you set
LD_LIBRARY_PATH for each one to be the right path, and not worry about
having it try to load the wrong shared libs.

On Fri, 6 Feb 2004, Wei Wang wrote:

> Thank you all for your kind help. I have set up 7.4.1 and it's up and
> running perfectly.
> One small question that might not belong in this mailing list:
> Since all the binary commands share the same name, e.g. initdb, createdb,
> psql, etc, and the
> default path is already the 7.1.3 version. How do I come up a way to access
> binary commands of
> both versions quickly without adding absolute path infront of those of
> 7.4.1?