SUSE Support

Here When You Need Us

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

SUSE Manager Server 4.2 

Situation

After migrating from SUSE Manager Server 4.1 to SUSE Manager Server 4.2,  the database migration  /usr/lib/susemanager/bin/pg-migrate-x-to-y.sh fails with following error message:
-----------------------------
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

Please refer to the following steps to create the template1 database:

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

1. For unknown reasons database template1 is missing.

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

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.