2

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.

Rich_F
  • 1,830
  • 3
  • 24
  • 45
  • 1
    Did you initialize the Postgres 10 data directory using `/usr/pgsql-10/bin/initdb -D /var/lib/pgsql/10/data` before running pg_upgrade? –  Nov 06 '18 at 07:10
  • @a_horse_with_no_name Yes I did. As it stands, starting `PostgreSQL` still launches `9.2`. So as I see it, the switchover to `10` is the only issue, which seems a permissions thing. – Rich_F Nov 06 '18 at 13:33

1 Answers1

0

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.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263