8

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

Thank you

6 Answers 6

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Is there a way to do it and use the same data directory?
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.

2 Comments

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.
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.
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.

Comments

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.

Comments

0

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

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.