问题
I'm trying to migrate PostgreSQL from 9.2 to 10.2 on CentOS 7
I've installed the new version, and I'm trying to implement the changeover:
/usr/pgsql-10/bin/pg_upgrade --old-datadir /var/lib/pgsql/data/ --new-datadir /var/lib/pgsql/10/data/ \
--old-bindir /usr/bin/ --new-bindir /usr/pgsql-10/bin/
The error I'm getting is:
could not open version file: /var/lib/pgsql/data/PG_VERSION
Failure, exiting
I try as root, and pg_upgrade
cannot be run as root.
/var/lib/pgsql
belongs to postgres:postgres so I'm at a bit of a loss how I can get this done.
Do I have to be a certain user to upgrade PostgreSQL using pg_upgrade
? How do I proceed to get this switched over to v10.2? I'm sure it's something I'm overlooking and simple.
回答1:
You must run pg_upgrade
as the user that owns both the new and the old data directories. That user is typically postgres
.
If /var/lib/pgsql/data/PG_VERSION
does not exist, /var/lib/pgsql/data
is no PostgreSQL data directory.
来源:https://stackoverflow.com/questions/53166580/centos-7-pg-upgrade-permissions-errors