These messages are dated yesterday. You should, I think, stop the service, backup the service file, edit it to have the path as previously described, and re-start the service.
You have a mis-match of versions and you need to have the service and the initdb using the same version.
Edited:
You might then want to post the new status output so that we can see if the edit helped.
The postgresql-old-upgrade package’s descriptions reads
Older PostgreSQL for migrating major versions with pg_upgrade
This looks like the OP cannot dump the old data with the new Postgres version he has installed now. Anyway, pg_upgrade is simpler and should do - at least it did for me.
I used to run a lot of Postgres, even clusters for work.
The in place pg_upgrade for every Postgres major version is the recommended way to go. Minor versions no problem. But major versions, every time. I would get process down if you have important data. It’s also much quicker.
Seems like you have given up on that, and want to export/import? Not as resilient. But works most the time, especially with simple DBs only used as a basic transactional database.
But I’m confused what or where this is headed now.
There is a mismatch of the PGROOT path. You initialised a different path for your data. But your service is configured with the default path. If your setup ever did work you changed the PGROOT path and most likely you did this:
And this isn’t the way since this will be lost on updates. Instead use
# systemctl edit unit --drop-in=drop_in_name
to overwrite the PGROOT setting.
Moreover, you don’t need any dump to upgrade (it’s for making backups). The better way is to use pg_upgrade.
Thanks, but I have in /var/lib/postgres/data/postgresql.conf and this had worked in the past.
#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------
# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.
#data_directory = 'ConfigDir' # use data in another directory
# (change requires restart)
# NEU 11.01.2021 UND 04.09.2025 data_directory definiert
data_directory = '/mnt/Daten/Technik/PostgreSQL/data'
#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
Nevertheless I have
[quote="MaMicha, post:14, topic:183753"]
Mine `/usr/lib/systemd/system/postgresql.service` is the same:
``
```
Environment=PGROOT=/var/lib/postgres
```
[/quote]
You need to fix the mismatch between the path used in initdb and in the service. People have suggested a few ways to fix this, but as far as I can tell you have not tried any of them. I don’t think i have anything else to suggest. Good luck.
Then you didn’t run Postgres as systemd service, which is possible, too. Or rather you did which is why there is an old version under the default path so now with the new version this fails to start.
The systemd service tells you there is an old database under ${PGROOT}/data and this is why it doesn’t start.
This is the systemd service’s PGROOT, so the old database is under /var/lib/postgres/data. In all your posts you never touched this path, so there was no change there, so it has the old version. The underlying problem is configuring the systemd service with a default location and at the same time setting the Postgres data location via the Postgres configuration to something else. Your setup was screwed before the upgrade (whether or how it worked who knows doesn’t matter) and the upgrade attempt only reveals this. Please read about it and notice the tip box (with green background)
If you change the root to something other than /var/lib/postgres , you will have to edit the service file. If the root is under home , make sure to set ProtectHome to false.
I don’t have my DB at the default location and all i did was to edit the service file - i can’t recall anything else like modifying the Postgres configuration.
This seems to be a typo. Other than this, yes /mnt/Daten/Technik/PostgreSQL would be your new PGROOT. I think the pg_upgrade may fail as i mentioned earlier because the change in check sums. In this case
Well, stop the Postgres service, switch to the postgres user, cd to the temporary directory and run the pg_upgrade command. If it fails with the check sum error i already posted the commands. Good luck.
$ sudo -i
# su postgres
# systemctl stop postgresql
# systemctl status postgresql # result: Dead!
[postgres]$ cd /mnt/Daten/Technik/PostgreSQL
[postgres]$ mv data olddata # SKIP, already done!!!
[postgres]$ rm -r data # Kill the old one
[postgres]$ mkdir /mnt/Daten/Technik/PostgreSQL/data
[postgres]$ chown postgres:postgres /mnt/Daten/Technik/PostgreSQL/data
[postgres]$ mkdir tmp
[postgres]$ cd tmp
$ sudo -i
[XYZ ~]# su postgres
[postgres@XYZ root]$ initdb -D /mnt/Daten/Technik/PostgreSQL/data
SUCCESS, Server can be started ...
exit
exit
[myName@XYZ qqtmp]$ pg_upgrade -b /opt/pgsql-17/bin -B /usr/bin -d /mnt/Daten/Technik/PostgreSQL/data17 -D /mnt/Daten/Technik/PostgreSQL/data
konnte Zugriffsrechte von Verzeichnis »/mnt/Daten/Technik/PostgreSQL/data« nicht lesen: Keine Berechtigung
Fehlgeschlagen, Programm wird beendet
[myName@XYZ qqtmp]$ sudo -i
[XYZ ~]# pg_upgrade -b /opt/pgsql-17/bin -B /usr/bin -d /mnt/Daten/Technik/PostgreSQL/data17 -D /mnt/Daten/Technik/PostgreSQL/data
pg_upgrade: kann nicht als root ausgeführt werden
Fehlgeschlagen, Programm wird beendet
[XYZ ~]# su postgres
[postgres@XYZ root]$ pg_upgrade -b /opt/pgsql-17/bin -B /usr/bin -d /mnt/Daten/Technik/PostgreSQL/data17 -D /mnt/Daten/Technik/PostgreSQL/data
Sie müssen Lese- und Schreibzugriff im aktuellen Verzeichnis haben.
Fehlgeschlagen, Programm wird beendet
[postgres@XYZ root]$ cd /mnt/Daten/qqtmp
[postgres@XYZ qqtmp]$ pg_upgrade -b /opt/pgsql-17/bin -B /usr/bin -d /mnt/Daten/Technik/PostgreSQL/data17 -D /mnt/Daten/Technik/PostgreSQL/data
Sie müssen Lese- und Schreibzugriff im aktuellen Verzeichnis haben.
Fehlgeschlagen, Programm wird beendet
pg_upgrade requires write permission in the current directory.
So I guess the postgres user does not have write access in /mnt/Daten/qqtmp - surely you can find a directory in which it can both read and write? Maybe the postgres user’s home directory, or /tmp, or something.
I think the actual data directories are probably okay, it is just that the pg_upgrade command is being issued in another directory. For instance, they tried running it in /mnt/Daten/qqtmp and we have no idea who actually owns that directory.
Thank you. The directory /mnt/Daten/qqtmp is owned by myself and I have write permission there. My guess is, the temporary directory must not be part of the data-directory (e.g. mnt/Daten/?
I could solve it by choosing /tmp as temporary directory. Doing this, the solutions (1) from @Phemisters and (2)@jofi worked. In general, this has been done:
$ pamac checkupdates
3 Aktualisierungen verfügbar:
postgresql 17.5-5 -> 18.1-1 extra
postgresql-libs 17.5-5 -> 18.1-1 extra
postgresql-old-upgrade 16.9-2 -> 17.7-1 extra
$ pamac update
$ sudo -i
# mv /mnt/Daten/Technik/PostgreSQL/data /mnt/Daten/Technik/PostgreSQL/data17
# rm -r /mnt/Daten/Technik/PostgreSQL/data # Remove the old and create a new data-dir
# mkdir /mnt/Daten/Technik/PostgreSQL/data
# chown postgres:postgres /mnt/Daten/Technik/PostgreSQL/data
# exit
$ sudo -i
# su postgres
[postgres@XYZ root]$ cd /tmp # IMPORTANT, do not use a directory within /mnt/Daten/...
[postgres@XYZ tmp]$ initdb -D /mnt/Daten/Technik/PostgreSQL/data --locale=C.UTF-8 --encoding=UTF8 --data-checksums
...
SUCCESS: You can start the Server now using:
pg_ctl -D /mnt/Daten/Technik/PostgreSQL/data -l logdatei start
[postgres@XYZ tmp]$ exit
exit
[XYZ ~]# exit
Abgemeldet
$ cd /tmp
$ sudo -i
[XYZ ~]# su postgres
[postgres@XYZ root]$ cd /tmp
[postgres@XYZ tmp]$ pg_upgrade -b /opt/pgsql-17/bin -B /usr/bin -d /mnt/Daten/Technik/PostgreSQL/data17 -D /mnt/Daten/Technik/PostgreSQL/data # pgsql-17 is present actually
Running consistency testing
-------------------------------
Running Upgrade
-------------------
...
Upgrade finished
---------------------
[postgres@XYZ tmp]$exit
exit
$ systemctl start postgresql.service