8

Is it possible to run Postgres 8.4 AND 9 at the same time (two installations)?

Thank you

code-gijoe
  • 6,949
  • 14
  • 67
  • 103

6 Answers6

7

Short answer: yes

Long answer:

You didn't specify your OS, so it's difficult to say how to do it. For example in Debian/Ubuntu you can just install second version from package (postgresql-8.4 and postgresql-9.0) and everything works out of the box (thanks to postgresql-common). On other systems you probably need to do it manually using "low level" commands such initdb and pg_ctl. Make sure that second installation (database cluster) uses different port (for example 5433) and not same data directory.

Grzegorz Szpetkowski
  • 36,988
  • 6
  • 90
  • 137
2

Yes, provided the following three preconditions are satisfied:

  1. PostgreSQL is listening on a unique IP/port (check out pgbouncer and you can probably hide both copies of PostgreSQL behind a single IP/port and reduce your memory footprint by reducing the number of active connections)
  2. You have enough SYSV shared memory available (this is frequently the limiting factor)
  3. You use different PGDATA directories.

I can't recommend using pgbouncer enough.

Sean
  • 9,888
  • 4
  • 40
  • 43
  • 2
    SYSV shared memory is not really a limiting factor, you just need to make sure you update the relevant kernel parameters (primarily SHMMAX) to more reasonable values than their tiny default. – Greg Smith Jun 25 '11 at 01:27
  • Absolutely! Though it's been my experience that timid system administrators have a tendency to get squeamish around several TLA's, notably 'shm*', 'ipc*' and 'sysv*'. :~] A small price to pay for awesomeness. – Sean Jun 25 '11 at 04:27
2

On Windows you don't need to do anything as the installer automatically creates unique data directories and detects an existing installation and adjusts the ports automatically.

For example - your first installation will listen on 5432 and your second installation will listen on 5433, as the installer configures this for you.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
1

You always can, the question is how hard it will be to install two versions at the same time, and that depends on your operating system. On RedHat Linux derived systems for example, this is very hard to do. The PostgreSQL RPM packages are only intended to have a single version installed at any one time. Sometimes the only reasonable way to proceed is to build your own PostgreSQL from source for the second version you want to install, which is an interesting adventure if you've never done it before.

On Debian Linux two versions at once is pretty easy. I believe it's straightforward on Windows too, but it may depend on which installer you are using.

Once you get two different versions of the database installed, only then do you have to worry about the things everyone else is talking about: making each database run on its own port and have its own installation directory. Those are often trivial compared with the work it takes to get two versions installed at once though.

Greg Smith
  • 16,965
  • 1
  • 34
  • 27
0

yes, you just put the data directores in different locations.

eggie5
  • 1,920
  • 18
  • 25
0

Yes you can. You'll need to run them on different ports and use different data directories.

The port and data directory can both be set in postgresql.conf.

There are I believe several other ways of specifying the data directory including using the PGDATA environment variable.

Will
  • 877
  • 11
  • 25