Thread: Poatgresql database on more than one disk

Poatgresql database on more than one disk

From
bgraetz@bigpond.net.au (Barry)
Date:
Hi All,

I am a newcommer to Postgresql, currently I am looking at moving
a Pick based application across to PostgreSQL.

I am using RH Linux and Postgresql 7.3.6

The test system I am using has a 2 channel raid card with a disk pack
connected to each channel. The OS and Postgresql sits on its own internal
disk.

I would like to be able to use one disk pack for development and the
other for end user testing / verification (the tape drive can only backup
one disk pack completely, not both)

I have spent a fair amount of time researching how I can run two
databases, one on each disk pack but have not been able to find a
solution.

Is it possible to configure Postgresql to have seperate databases
on seperate disks ?

TIA

Barry

Re: Poatgresql database on more than one disk

From
"Philip A. Chapman"
Date:
On Tue, 2004-05-25 at 18:33, Barry wrote:
> I would like to be able to use one disk pack for development and the
> other for end user testing / verification (the tape drive can only backup
> one disk pack completely, not both)
>
> Is it possible to configure Postgresql to have seperate databases
> on seperate disks ?
>

One solution is to run two postmasters (two services).  Each would use a
different value for the PGDATA environment variable.

The pro to this is that there would be a greater degree of separation
between your development environment and test environment.  You could
start and stop the development environment service separately from the
test environment, for instance.

The con is that only one postmaster can bind to port 5432 at a time.
You would have to set up one of the postmasters to use a different
port...  perhaps 5433?

Since you are using RedHat, take a look at /etc/init.d/postgresql.  You
should see where the the PGDATA environment variable is set in the top
of the script.  PGPORT is also set, which is the port number that the
postmaster will use.  (I am using Fedora Core 1 and Fedora Core 2.  I
assume that RedHat's scripts are very similar to this, if not
identical).

If I were doing it, I'd probably copy /etc/init.d/postgresql to
/etc/init.d/postgresql_dev and /etc/init.d/postgresql_test.  I'd modify
/etc/init.d/postgresql_test so that it controls my test environment and
/etc/init.d/postgresql_dev so that it controls my development
environment.  I'd use chkconfig to disable the service postgresql and
enable the services postgresql_dev and postgresql_test.  (That way, if
upgrades clobber /etc/init.d/postgresql, you're not left in a bind).

You can contact me off-list if you need more help with this solution.

--
Philip A. Chapman

Application Development:
Java, Visual Basic (MCP), PostgreSQL, MySQL, MSSQL
Linux, Windows 9x, Windows NT, Windows 2000, Windows XP

Attachment

Re: Poatgresql database on more than one disk

From
Jim Rosenberg
Date:
--On Monday, May 31, 2004 2:14 PM -0500 "Philip A. Chapman"
<pchapman@pcsw.us> wrote:

> On Tue, 2004-05-25 at 18:33, Barry wrote:

>> Is it possible to configure Postgresql to have seperate databases
>> on seperate disks ?
>>
>
> One solution is to run two postmasters (two services).  Each would use a
> different value for the PGDATA environment variable.

Pardon me for being dense, but I don't see how, with this approach, you
maintain transaction integrity between the two databases. Suppose you need
a transaction involving tables from both databases. Can you explain how you
achieve this?


Re: Poatgresql database on more than one disk

From
Karsten Hilbert
Date:
> Pardon me for being dense, but I don't see how, with this approach, you
> maintain transaction integrity between the two databases. Suppose you need
> a transaction involving tables from both databases. Can you explain how you
> achieve this?

You can't anyways (server side) no matter where the two
separate databases reside unless you use contrib/dblink in
which case it again matters not where the databases reside.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346