Moving database cluster

Lists: pgsql-general
From: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Moving database cluster
Date: 2010-01-14 20:40:39
Message-ID: A9C1544955E84DBB85C0501BA96E436C@iptel.com.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


An Ubuntu install creates a postgres cluster automatically on
/var/lib/postgresql/8.4/main
Whats the best procedure for moving this cluster to an other location?
Should I just rerun initdb? What happens then with the default cluster or
how could I delete it?

Thanks,
Fernando.


From: "Joshua J(dot) Kugler" <joshua(at)eeinternet(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
Subject: Re: Moving database cluster
Date: 2010-01-14 20:47:58
Message-ID: 201001141147.58876.joshua@eeinternet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thursday 14 January 2010, Fernando Hevia elucidated thus:
> An Ubuntu install creates a postgres cluster automatically on
> /var/lib/postgresql/8.4/main
> Whats the best procedure for moving this cluster to an other
> location? Should I just rerun initdb? What happens then with the
> default cluster or how could I delete it?

The easiest way is to shut down Pg, move the 'main' directory somewhere
else, and then point a symlink to the new location.

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0x14EA086E


From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Fernando Hevia <fhevia(at)ip-tel(dot)com(dot)ar>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Moving database cluster
Date: 2010-01-14 20:52:50
Message-ID: 4B4F8422.2030708@lelarge.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Le 14/01/2010 21:40, Fernando Hevia a écrit :
>
> An Ubuntu install creates a postgres cluster automatically on
> /var/lib/postgresql/8.4/main
> Whats the best procedure for moving this cluster to an other location?
> Should I just rerun initdb? What happens then with the default cluster or
> how could I delete it?
>

If you don't have any data on it, the best way is to drop it with
pg_dropcluster, and create a new one with pg_createcluster.

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com


From: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
To: "'Guillaume Lelarge'" <guillaume(at)lelarge(dot)info>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Moving database cluster
Date: 2010-01-14 21:21:14
Message-ID: 87B0B7A9F2E449F6A5D082D502F11447@iptel.com.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> -----Mensaje original-----
> De: Guillaume Lelarge [mailto:guillaume(at)lelarge(dot)info]
>
> Le 14/01/2010 21:40, Fernando Hevia a écrit :
> >
> > An Ubuntu install creates a postgres cluster automatically on
> > /var/lib/postgresql/8.4/main Whats the best procedure for
> moving this
> > cluster to an other location?
> > Should I just rerun initdb? What happens then with the
> default cluster
> > or how could I delete it?
> >
>
> If you don't have any data on it, the best way is to drop it
> with pg_dropcluster, and create a new one with pg_createcluster.
>
>

Sound advice. Thanks!!


From: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
To: "'Joshua J(dot) Kugler'" <joshua(at)eeinternet(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Moving database cluster
Date: 2010-01-14 21:38:52
Message-ID: EA81CEE83870476C91220DD395C96A9A@iptel.com.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> -----Mensaje original-----
> De:
>
> On Thursday 14 January 2010, Fernando Hevia elucidated thus:
> > An Ubuntu install creates a postgres cluster automatically on
> > /var/lib/postgresql/8.4/main Whats the best procedure for
> moving this
> > cluster to an other location? Should I just rerun initdb?
> What happens
> > then with the default cluster or how could I delete it?
>
> The easiest way is to shut down Pg, move the 'main' directory
> somewhere else, and then point a symlink to the new location.
>

Thanks for your reply.
I had considered this first but then I wasn't sure if there would be any
performance penalty.
The current main directory sits on a 'slow' RAID 1 volume while the new one
will sit on a 'fast' 12 disk RAID 10 volume.
I guess the symlink shouldn't be troublesome but I don't know if some PG
process will continually be reading this link encumbering somehow the RAID 1
disks.

Regards,
Fernando.


From: "Joshua J(dot) Kugler" <joshua(at)eeinternet(dot)com>
To: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Moving database cluster
Date: 2010-01-14 21:55:04
Message-ID: 201001141255.04813.joshua@eeinternet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thursday 14 January 2010, Fernando Hevia elucidated thus:
> > The easiest way is to shut down Pg, move the 'main' directory
> > somewhere else, and then point a symlink to the new location.
>
> Thanks for your reply.
> I had considered this first but then I wasn't sure if there would be
> any performance penalty.
> The current main directory sits on a 'slow' RAID 1 volume while the
> new one will sit on a 'fast' 12 disk RAID 10 volume.
> I guess the symlink shouldn't be troublesome but I don't know if some
> PG process will continually be reading this link encumbering somehow
> the RAID 1 disks.

I'm not sure how Pg does it, but I remember reading several years ago
that MySQL would, upon startup, "resolve" the symlink, and use the real
path name for the rest of its execution. I would assume Pg does
something similar.

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0x14EA086E


From: David Kerr <dmk(at)mr-paradox(dot)net>
To: Fernando Hevia <fhevia(at)ip-tel(dot)com(dot)ar>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Moving database cluster
Date: 2010-01-14 23:55:55
Message-ID: 20100114235555.GR29521@mr-paradox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, Jan 14, 2010 at 06:21:14PM -0300, Fernando Hevia wrote:
-
-
- > -----Mensaje original-----
- > De: Guillaume Lelarge [mailto:guillaume(at)lelarge(dot)info]
- >
- > Le 14/01/2010 21:40, Fernando Hevia a écrit :
- > >
- > > An Ubuntu install creates a postgres cluster automatically on
- > > /var/lib/postgresql/8.4/main Whats the best procedure for
- > moving this
- > > cluster to an other location?
- > > Should I just rerun initdb? What happens then with the
- > default cluster
- > > or how could I delete it?
- > >
- >
- > If you don't have any data on it, the best way is to drop it
- > with pg_dropcluster, and create a new one with pg_createcluster.
- >
- >
-
- Sound advice. Thanks!!

in SLES, assuming you have no data in the DB, I'd go to /etc/sysconfig/postgresql
modify POSTGRES_DATADIR="/my/new/path"

and then (logout/log back in to get your PGDATA set correctly and )
initdb

No need to mess with symlinks.

I'm sure ubuntu has something similar to sysconfig

Dave