Description of problem:
The upgrade script appears to not know where to find the PGDATA dir and there appears to be no way of telling it.
It complains about the /var/lib/psql/data-old directory and the following line was failing:
"/usr/lib64/pgsql/postgresql-10/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/data-old" -o "-p 5432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/pgsql'" start
Changing it to:
sudo -u postgres "/usr/lib64/pgsql/postgresql-10/bin/pg_ctl" -w -l "/var/lib/pgsql/pg_upgrade_server.log" -D "/var/lib/pgsql/data" -o "-p 5432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/pgsql'" start
Does work for that step but it fails again later looking for data-old.
Using --datadir with the command is deprecated, instead --unit is recommended.
sudo -u postgres postgresql-setup --upgrade --unit /usr/lib/systemd/system/postgresql.service
Fails because PGDATA is not set, but it is in the Environment= in that file.
Per postgresql-setup --help:
--unit=UNIT_NAME The UNIT_NAME is used to select proper unit
configuration (unit == service or initscript name
on non-systemd systems). For example, if you want
to work with unit called
'postgresql@com_example.service', you should use
'postgresql@com_example' (without trailing .service
string). When no UNIT_NAME is explicitly passed,
the 'postgresql' string is used by default.
Yes, we should support both absolute name of service file, and with/without
the `.service` suffix -- but it is not yet supported.