0

Apologies in advance if this is a stupid question - I am a developer not a sysadmin.

Since running apt-get update/upgrade on my ubuntu VM (Oracle VirtualBox) I cannot seem to get my postgresql database online. I believe this is may be because postgresql-15 has been upgraded from beta-3 to beta-4.

This is a real nuisance for me because it has trashed our development environment. (I am assuming when we are ready to release 15 will be fully available and I would really like to be able to use merge statements in my code)

I wiped postgresql from the host and am now attempting a fresh install following these instructions.

At Step 3. sudo -u postgres psql I receive the follwing error : psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?

which, essentially, is the problem I was faced with after the failed upgrade (despite having run systemctl start postgresql)

Can anyone advise what it is I need to do to get postgres-15 (preferably beta-4) up and running?


hugh@ububtuvm:~$ systemctl status postgresql ● postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor p> Active: active (exited) since Sun 2022-09-18 10:47:19 UTC; 31min ago Process: 2349 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 2349 (code=exited, status=0/SUCCESS) CPU: 905us Sep 18 10:47:19 ububtuvm systemd[1]: Starting PostgreSQL RDBMS... Sep 18 10:47:19 ububtuvm systemd[1]: Finished PostgreSQL RDBMS. hugh@ububtuvm:~$ journalctl -xeu postgresql.service ░░ Subject: A stop job for unit postgresql.service has begun execution ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A stop job for unit postgresql.service has begun execution. ░░ ░░ The job identifier is 1675. Sep 18 10:47:19 ububtuvm systemd[1]: Starting PostgreSQL RDBMS... ░░ Subject: A start job for unit postgresql.service has begun execution ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit postgresql.service has begun execution. ░░ ░░ The job identifier is 1675. Sep 18 10:47:19 ububtuvm systemd[1]: Finished PostgreSQL RDBMS. ░░ Subject: A start job for unit postgresql.service has finished successfully ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit postgresql.service has finished successfully. ░░ ░░ The job identifier is 1675. 

root@ubuntuvm:/home/hugh# cat /usr/lib/systemd/system/postgresql.service # postgresql.service is the meta unit for managing all PostgreSQL clusters on # the system at once. Conceptually, this unit is more like a systemd target, # but we are using a service since targets cannot be reloaded. # # The unit actually managing PostgreSQL clusters is [email protected], # instantiated as [email protected] for individual clusters. [Unit] Description=PostgreSQL RDBMS [Service] Type=oneshot ExecStart=/bin/true ExecReload=/bin/true RemainAfterExit=on [Install] WantedBy=multi-user.target 

(installed by apt install)


I found this which contains the following paragraphs.

After updating from an alpha or beta release I get an error about CATALOG_VERSION After upgrading from an alpha or beta package, I get an error like:

The database cluster was initialized with CATALOG_VERSION_NO X, but the server was compiled with CATALOG_VERSION_NO Y. This is because the PostgreSQL data format can change between alpha releases - and occasionally even between beta releases if there's a really pressing need.

If you need to access the old data, you will need to use the package version you were running before, and use pg_dump or pg_upgrade. The necessary binaries should have been saved in /var/tmp/postgresql*. Alternatively, look for the old packages in your /var/cache/apt/archives.

I am still struggling, though - I have not found the previous version anywhere yet.

4
  • Can you share the output of systemctl status postgresql and journalctl -xeu postgresql.service? Commented Sep 18, 2022 at 11:11
  • @skipper - hey, thanks for the very quick response Commented Sep 18, 2022 at 11:22
  • @larsks - the service definition may have been already installed from the beta-3 installation (which worked). Commented Sep 18, 2022 at 12:21
  • It looks like the ubuntu postgres unit does some funky stuff with systemd generators, which means things like journalctl -u postgres probably won't give us the information we're looking for. I'm taking a closer look at how things are set up right now (and I've removed my previous comment). Commented Sep 18, 2022 at 12:29

1 Answer 1

3

Ubuntu has some clever support for running multiple postgres instances. The postgresql.service unit is just a dummy unit: it does nothing but run /bin/true. This may seem useless, but it's not! The key is that it is the dependencies of this unit that are important, and those are generated dynamically at boot time by /lib/systemd/system-generators/postgresql-generator.

This looks at all the /etc/postgresql/*/*/postgresql.conf files on your system and uses these to generate instances of the [email protected] template unit.

When you install the postgresql-15 package, this should:

  1. Provide the file /etc/postgresql/15/main/postgresql.conf (and other files in that directory), and
  2. Automatically start the [email protected] unit.

I've reproduced this on an Ubuntu 22.04 system, where I started with postgresql-14, then installed postgresql-15 following the link in your question, and now I have:

root@ubuntu:~# systemctl list-units postgresql\* UNIT LOAD ACTIVE SUB DESCRIPTION postgresql.service loaded active exited PostgreSQL RDBMS [email protected] loaded active running PostgreSQL Cluster 14-main [email protected] loaded active running PostgreSQL Cluster 15-main 

I can successfully connect to the database, but since here I'm running two different postgres instances I need to specify an explicit port. Looking at the config files in /etc/postgresql/..., I see that my postgres 15 instance is using port 5433, so I run:

root@ubuntu:/# sudo -u postgres psql -p 5433 psql (15beta4 (Ubuntu 15~beta4-1.pgdg22.04+1)) Type "help" for help. postgres=# 

If the Postgresql 15 service fails to start, to see the service status I would run:

systemctl status [email protected] 

And to see the logs I would run:

journalctl -u [email protected] 
4
  • thanks for the information. I removed postgres-14 some time ago. I will start again from scratch with postgres-14, then add 15 and see what I can glean from that. Commented Sep 18, 2022 at 19:36
  • I'm not sure you need to do that: I would just take a look at your postgres 15 configuration: You know from the above which service to look at for error messages, so I would start there. You can also double check to see which port the postgres 15 instance is using; this affects the unix socket name, as I demonstrated here. Commented Sep 18, 2022 at 21:03
  • my 'base' error with a single instance of postgres-15 is "database files are incompatible with server". This started to occur when apt upgraded. I have no postgres-14 currently, just a single 15/main cluster. I believe what I need to do is get 15-beta-3 running again so I can dump the database, rerun the upgrade, then import. Commented Sep 19, 2022 at 9:35
  • I solved my problem by copying the data files from the ubuntu vm to a new Fedora vm. Beta-3 was easy to find as rpms. From there I did a pg_dumpall which I was able to import into the beta-4 db. Commented Sep 24, 2022 at 7:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.