If the existing main
is the default cluster that was created with your installation you can just drop it. Use the tool provided by your installation:
pg_dropcluster --stop 9.1 main
More info: man pg_dropcluster
There is nothing special about the main
cluster. It's just a cluster like any other which happens to be the default in your installation.
If you haven't worked with the cluster yet, there is nothing in there, that you would lose. But check with psql or pgAdmin (or a client of your choosing) to make sure.
It appears you have an 8.4 database that isn't managed by pg_wrapper
, and have installed 9.2 from Ubuntu packages and allowed it to create a pg_wrapper
managed cluster in the default location, which isn't where you want the DB.
pg_upgradecluster
from pg_wrapper
isn't suitable for this, since you hand-initdb'd the old cluster.
If the 9.2 cluster doesn't have any data of value in it yet, drop it, destroying all its data:
pg_dropcluster 9.2 main
Then re-create it in the desired location. Assuming your mounted HD's root is /mydata
, you'd:
pg_createcluster -d /mydata/pgdata_9.2_main 9.2 main
Now dump the old database and load it into the new one. Start both 8.4 and 9.1 on different ports; I'll assume 8.4 is on 5432 (default) and 9.2 is on 5433. Something like this should copy the dump from one directly into the other. Make sure you use the 9.1 versions of pg_dumpall
and psql
:
sudo -u postgres pg_dumpall -p 5432 | sudo -u postgres psql -p 5433
... but personally I'd do a pg_dumpall --globals-only
using the 9.2 pg_dumpall
against the 8.4 DB, followed by individual pg_dump
s of each database in the old cluster (again using the 9.2 pg_dump
). I'd then restore the globals dump followed by each individual dump into the new cluster.
Alternately, you can drop the pg_wrapper
managed 9.2 cluster, not re-create it, and follow the instructions for pg_upgrade
to do a binary upgrade from the 8.4 to the 9.2 DB. This will create a DB that is not managed by pg_wrapper
. You can either convert it to be managed by pg_wrapper
by moving and symlinking postgresql.conf
and pg_hba.conf
, or you can just manage it like you did 8.4, using your own init scripts.
Best Answer
If you create a cluster in Debian/Ubuntu without specifying the owner (option
--user
ofpg_createcluster
) then you have to be sure that the directory you specify is accessibile in r/w to thepostgres
user. Please note that all parent directories should also be accessibile to the same user with bitx
(list directory content).Otherwise, you may specify a different owner using option
--user
. This should create a cluster ran by that user instead ofpostgres
.In order to check if postgres user may access that directory, execute this command:
and check for any error.