Обсуждение: Moving Database -> New Disk

Поиск
Список
Период
Сортировка

Moving Database -> New Disk

От
"Tim Perdue, Directricity.com"
Дата:
I'm trying to do somethat that shouldn't be so darn difficult - moving a
database to a new bigger disk.

The database is db_domain at /usr/local/pgsq/data/base/db_domain

I want it to reside on /fireball/pgsql/...

I created a dump of db_domain and was able to do initdb on the new
location - but when I try to createdb, of course db_domain is already taken.
If I try to createdb using the -D switch I get an error about it not being
able to find the directory (it's there).

If I don't specify the -D switch, any new database is created under
/usr/local/pgsql/data/base/, even though I restarted postmaster with -D
pointing to /fireball/pgsql/....

So Could someone give some specific instructions on moving db_domain over to
the new hard disk? If there's a FAQ please give a full URL to find it.

Tim


Re: [SQL] Moving Database -> New Disk

От
Fabrice Scemama
Дата:
What about using a symlink ?
mv /usr/local/pgsql /fireball
ln -s /fireball/pgsql /usr/local/pgsql

Should do the whole trick.

Fabrice

"Tim Perdue, Directricity.com" wrote:
>
> I'm trying to do somethat that shouldn't be so darn difficult - moving a
> database to a new bigger disk.
>
> The database is db_domain at /usr/local/pgsq/data/base/db_domain
>
> I want it to reside on /fireball/pgsql/...
>
> I created a dump of db_domain and was able to do initdb on the new
> location - but when I try to createdb, of course db_domain is already taken.
> If I try to createdb using the -D switch I get an error about it not being
> able to find the directory (it's there).
>
> If I don't specify the -D switch, any new database is created under
> /usr/local/pgsql/data/base/, even though I restarted postmaster with -D
> pointing to /fireball/pgsql/....
>
> So Could someone give some specific instructions on moving db_domain over to
> the new hard disk? If there's a FAQ please give a full URL to find it.
>
> Tim



Re: Moving Database -> New Disk

От
Tom Lane
Дата:
"Tim Perdue, Directricity.com" <tim@directricity.com> writes:
> I'm trying to do somethat that shouldn't be so darn difficult - moving a
> database to a new bigger disk.
> The database is db_domain at /usr/local/pgsq/data/base/db_domain
> I want it to reside on /fireball/pgsql/...
> I created a dump of db_domain and was able to do initdb on the new
> location - but when I try to createdb, of course db_domain is already taken.

It sounds like createdb is connecting to your old postmaster.

> If I try to createdb using the -D switch I get an error about it not being
> able to find the directory (it's there).

createdb's -D is a weird critter that does not have at all the same
meaning as -D in the postmaster.  You're still connecting to the same
Postgres installation, you are just telling the system to put the
subdirectory for the particular database in a nonstandard place rather
than under installation-data-directory/base/.

Your message is actually not very clear about whether you want to move
the entire Postgres installation (all of /usr/local/pgsql/data/) or
just the one database (/usr/local/pgsql/data/base/db_domain/).  Either
is possible.

> If I don't specify the -D switch, any new database is created under
> /usr/local/pgsql/data/base/, even though I restarted postmaster with -D
> pointing to /fireball/pgsql/....

Hmm, sure sounds like the postmaster's -D didn't "take".  You might want
to double check that you gave it correctly.  Alternatively, rebuild your
Postgres software with the correct data directory specified at configure
time (I know this works, not sure whether -D really works or not...)

Someone else's suggestion of a symlink would also work.

            regards, tom lane