The most common error I get running these commands is after I run:
if pg_lsclusters -h | grep -q '^9\.6 '; then
pg_upgradecluster 9.6 main
elif pg_lsclusters -h | grep -q '^9\.4 '; then
pg_upgradecluster 9.4 main
fi
I will in most cases get:
Stopping old cluster...
Disabling connections to the old cluster during upgrade...
Restarting old cluster with restricted connections...
Creating new PostgreSQL cluster 11/main ...
/usr/lib/postgresql/11/bin/initdb -D /var/lib/postgresql/11/main --auth-local peer --auth-host md5 --encoding UTF8 --lc-collate de_DE.UTF-8 --lc-ctype de_DE.UTF-8
Die Dateien, die zu diesem Datenbanksystem gehören, werden dem Benutzer
»postgres« gehören. Diesem Benutzer muss auch der Serverprozess gehören.
Der Datenbankcluster wird mit der Locale »de_DE.UTF-8« initialisiert werden.
Die Standardtextsuchekonfiguration wird auf »german« gesetzt.
Datenseitenprüfsummen sind ausgeschaltet.
berichtige Zugriffsrechte des bestehenden Verzeichnisses /var/lib/postgresql/11/main ... ok
erzeuge Unterverzeichnisse ... ok
wähle Vorgabewert für max_connections ... 100
wähle Vorgabewert für shared_buffers ... 128MB
wähle Vorgabewert für timezone ... Europe/Berlin
wähle Implementierung von dynamischem Shared Memory ... posix
erzeuge Konfigurationsdateien ... ok
führe Bootstrap-Skript aus ... ok
führe Post-Bootstrap-Initialisierung durch ... ok
synchronisiere Daten auf Festplatte ... ok
Erfolg. Sie können den Datenbankserver jetzt mit
pg_ctlcluster 11 main start
starten.
Ver Cluster Port Status Owner Data directory Log file
11 main 5433 down postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log
Disabling connections to the new cluster during upgrade...
Failed to start postgresql@11-main.service: Unit postgresql@11-main.service is masked.
Error: Could not start target cluster
So it seams to me that a unmask command is missing in the how-to.
At least I had more success with adding:
I get the same error although postgres11/autostart was set. I’m using the following script to perform the update which throws the error above without the systemctl unmask:
#!/usr/bin/env bash
# Based on https://help.univention.com/t/updating-from-postgresql-9-6-or-9-4-to-postgresql-11/17531
set -ex
if [[ "$(lsb_release --release --short)" != "10" ]]; then
echo "Script can only run on UCS 5.0"
exit 1
fi
function assert_directory_does_not_exist() {
if [[ -d "${1}" ]]; then
echo "Directory ${1} already exists and would be overwritten."
echo "Please create backups if necessary and remove the directory."
exit 1
fi
}
function assert_postgres_property() {
local property="${1}"
local expected="${2}"
local found="${3}"
if [[ "${expected}" != "${found}" ]]; then
echo "The currently running PostgreSQL ${property} is not as expected!"
echo "Found: ${found}"
echo "Expected: ${expected}"
exit 1
fi
}
RUNNING_CLUSTERS="$(pg_lsclusters --no-header | grep online)"
assert_postgres_property "clusters count" "1" $(echo "${RUNNING_CLUSTERS}" | wc -l)
CURRENT_POSTGRES_VERSION="$(echo ${RUNNING_CLUSTERS} | cut -d' ' -f1)"
assert_postgres_property "version" "9.6" "${CURRENT_POSTGRES_VERSION}"
CURRENT_POSTGRES_CLUSTER="$(echo ${RUNNING_CLUSTERS} | cut -d' ' -f2)"
assert_postgres_property "cluster" "main" "${CURRENT_POSTGRES_CLUSTER}"
WANTED_POSTGRES_VERSION="11"
assert_directory_does_not_exist "/etc/postgresql/${WANTED_POSTGRES_VERSION}"
assert_directory_does_not_exist "/var/lib/postgresql/${WANTED_POSTGRES_VERSION}/main"
PKDB_SCAN_PATH="/usr/sbin/univention-pkgdb-scan"
if [[ -f "${PKDB_SCAN_PATH}" ]]; then
chmod -x "${PKDB_SCAN_PATH}"
fi
systemctl stop postgresql.service
ucr set "postgres${WANTED_POSTGRES_VERSION}/autostart=yes"
# A notification will pop up informing the user that Postgres 9.6 packages are still installed
# althoguh they are deprecated. We pass `--assume-yes` to suppress these.
apt-get install --reinstall --assume-yes "postgresql-${WANTED_POSTGRES_VERSION}"
# See https://help.univention.com/t/errors-updating-to-postgresql-11-with-kb-article/19491
systemctl unmask "postgresql@${WANTED_POSTGRES_VERSION}-${CURRENT_POSTGRES_CLUSTER}.service"
pg_upgradecluster -v "${WANTED_POSTGRES_VERSION}" \
--no-start \
"${CURRENT_POSTGRES_VERSION}" \
"${CURRENT_POSTGRES_CLUSTER}"
ucr commit "/etc/postgresql/${WANTED_POSTGRES_VERSION}/${CURRENT_POSTGRES_CLUSTER}/"
chown -R postgres:postgres "/var/lib/postgresql/${WANTED_POSTGRES_VERSION}"
systemctl restart postgresql.service
if [[ -f "${PKDB_SCAN_PATH}" ]]; then
chmod -x "${PKDB_SCAN_PATH}"
fi
univention-install --yes "univention-postgresql-${WANTED_POSTGRES_VERSION}"