correcting tablespaces inside data folder

Started by Duarte Carreiraalmost 8 years ago6 messagesgeneral
Jump to latest
#1Duarte Carreira
dncarreira@gmail.com

Hello.

Yes I'm one of those guys who only recently realized the mess of having
tablespaces inside the data directory... now I want to use pg_upgrade and
it will make things even worse...

Does anyone have a best approach to this problem? Fastest/safest?

pg 9.3.x on win

Thanks,
Duarte

#2Magnus Hagander
magnus@hagander.net
In reply to: Duarte Carreira (#1)
Re: correcting tablespaces inside data folder

On Fri, Jul 6, 2018 at 6:42 PM, Duarte Carreira <dncarreira@gmail.com>
wrote:

Hello.

Yes I'm one of those guys who only recently realized the mess of having
tablespaces inside the data directory... now I want to use pg_upgrade and
it will make things even worse...

Does anyone have a best approach to this problem? Fastest/safest?

pg 9.3.x on win

If you can afford to shut the server down, the easiest is to shut it down,
move the tablespaces (with mv, and as long as you stay within the partition
it should be almost instant), update the symlinks to point to the new
location, and start it up again.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

#3Duarte Carreira
dncarreira@gmail.com
In reply to: Magnus Hagander (#2)
Re: correcting tablespaces inside data folder

Magnus,
You mean changing the symlinks inside pg_tblspc?

On Fri, Jul 6, 2018 at 5:49 PM Magnus Hagander <magnus@hagander.net> wrote:

Show quoted text

On Fri, Jul 6, 2018 at 6:42 PM, Duarte Carreira <dncarreira@gmail.com>
wrote:

Hello.

Yes I'm one of those guys who only recently realized the mess of having
tablespaces inside the data directory... now I want to use pg_upgrade and
it will make things even worse...

Does anyone have a best approach to this problem? Fastest/safest?

pg 9.3.x on win

If you can afford to shut the server down, the easiest is to shut it down,
move the tablespaces (with mv, and as long as you stay within the partition
it should be almost instant), update the symlinks to point to the new
location, and start it up again.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

#4Magnus Hagander
magnus@hagander.net
In reply to: Duarte Carreira (#3)
Re: correcting tablespaces inside data folder

(please don't top-post. It makes it hard to follow discussions)

On Fri, Jul 6, 2018 at 7:05 PM, Duarte Carreira <dncarreira@gmail.com>
wrote:

Magnus,
You mean changing the symlinks inside pg_tblspc?

Yes. As long as the server is shut down, you can modify those symlinks.

On Fri, Jul 6, 2018 at 5:49 PM Magnus Hagander <magnus@hagander.net>
wrote:

On Fri, Jul 6, 2018 at 6:42 PM, Duarte Carreira <dncarreira@gmail.com>
wrote:

Hello.

Yes I'm one of those guys who only recently realized the mess of having
tablespaces inside the data directory... now I want to use pg_upgrade and
it will make things even worse...

Does anyone have a best approach to this problem? Fastest/safest?

pg 9.3.x on win

If you can afford to shut the server down, the easiest is to shut it
down, move the tablespaces (with mv, and as long as you stay within the
partition it should be almost instant), update the symlinks to point to the
new location, and start it up again.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

#5Duarte Carreira
dncarreira@gmail.com
In reply to: Magnus Hagander (#4)
Re: correcting tablespaces inside data folder

On Fri, Jul 6, 2018 at 6:15 PM Magnus Hagander <magnus@hagander.net> wrote:

(please don't top-post. It makes it hard to follow discussions)

On Fri, Jul 6, 2018 at 7:05 PM, Duarte Carreira <dncarreira@gmail.com>
wrote:

Magnus,
You mean changing the symlinks inside pg_tblspc?

Yes. As long as the server is shut down, you can modify those symlinks.

Ok, I'll try on my laptop and see how it goes.
Thanks.

Show quoted text

On Fri, Jul 6, 2018 at 5:49 PM Magnus Hagander <magnus@hagander.net>
wrote:

On Fri, Jul 6, 2018 at 6:42 PM, Duarte Carreira <dncarreira@gmail.com>
wrote:

Hello.

Yes I'm one of those guys who only recently realized the mess of having
tablespaces inside the data directory... now I want to use pg_upgrade and
it will make things even worse...

Does anyone have a best approach to this problem? Fastest/safest?

pg 9.3.x on win

If you can afford to shut the server down, the easiest is to shut it
down, move the tablespaces (with mv, and as long as you stay within the
partition it should be almost instant), update the symlinks to point to the
new location, and start it up again.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

#6Duarte Carreira
dncarreira@gmail.com
In reply to: Duarte Carreira (#5)
Re: correcting tablespaces inside data folder

Hi.
On Fri, Jul 6, 2018 at 6:30 PM Duarte Carreira <dncarreira@gmail.com> wrote:

On Fri, Jul 6, 2018 at 6:15 PM Magnus Hagander <magnus@hagander.net>
wrote:

(please don't top-post. It makes it hard to follow discussions)

On Fri, Jul 6, 2018 at 7:05 PM, Duarte Carreira <dncarreira@gmail.com>
wrote:

Magnus,
You mean changing the symlinks inside pg_tblspc?

Yes. As long as the server is shut down, you can modify those symlinks.

Ok, I'll try on my laptop and see how it goes.
Thanks.

Update: everything seems to be working fine.
On windows you can't change the symlinks (called junctions on windows). You
have to delete them with rd symlimk_id, and then recreate them pointing to
the new location with:
mklink /J symlink_id path_to_new_location

Have to be specially carefull to recreate the symlinks correctly!

Thanks again.
Duarte

Show quoted text

On Fri, Jul 6, 2018 at 5:49 PM Magnus Hagander <magnus@hagander.net>
wrote:

On Fri, Jul 6, 2018 at 6:42 PM, Duarte Carreira <dncarreira@gmail.com>
wrote:

Hello.

Yes I'm one of those guys who only recently realized the mess of
having tablespaces inside the data directory... now I want to use
pg_upgrade and it will make things even worse...

Does anyone have a best approach to this problem? Fastest/safest?

pg 9.3.x on win

If you can afford to shut the server down, the easiest is to shut it
down, move the tablespaces (with mv, and as long as you stay within the
partition it should be almost instant), update the symlinks to point to the
new location, and start it up again.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;