PostgreSQL migration failed after SUSE Manager Server 4.1 migration to 4.2
This document (000020664) is provided subject to the disclaimer at the end of this document.
Environment
Situation
-----------------------------
Checking cluster versions ok
connection to database failed: connection to server on socket "/var/lib/pgsql/.s.PGSQL.50432" failed: FATAL: database "template1" does not exist
could not connect to source postmaster started with the command:
"/usr/lib/postgresql12/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/data-pg12" -o "-p 50432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_direc
tories='/var/lib/pgsql'" start
Failure, exiting
01:40:29 Upgrading database to version 13 failed!
Resolution
1. Stop spacewalk-service
# spacewalk-service stop
2. Check PostgreSQL service status:
# systemctl status postgresql.service
3. Start PostgreSQL service:
# systemctl start postgresql.service
4. Create the template1 database:
# su - postgres
# psql
postgres=# create database template1 template=template0;
CREATE DATABASE
postgres=# update pg_database set datistemplate = true where datname='template1';
UPDATE 1
postgres=#
5. Stop PostgreSQL service:
# systemctl stop postgresql.service
6. Remove or move the directory containing the incorrectly initialized database, then run the migration script again, the migration should work:
# rm -rf /var/lib/pgsql/data-new-failed
# /usr/lib/susemanager/bin/pg-migrate-x-to-y.sh
... or ...
# mv /var/lib/pgsql/data-new-failed /var/lib/pgsql/data-new-failed-backup
# /usr/lib/susemanager/bin/pg-migrate-x-to-y.sh
Cause
2. Template1 was deleted by mistake.
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000020664
- Creation Date: 02-Jun-2022
- Modified Date:03-Jun-2022
-
- SUSE Manager Server
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com