Database Migration

This is about PostgreSQL database migration.

If you want to upgrade SUSE Manager 3.2 to SUSE Manager 4 you must check whether SUSE Manager 3.2 is already based on PostgreSQL version 10. If you are already using PostreSQL version 10, skip this section. If you are using an older version, such as version 9.6, you must migrate PostgreSQL to version 10 before you begin the database migration. For more information about migrating PostgreSQL 9.6 to version 10, see Prepare to Upgrade. If you run PostgreSQL 9.4 on SUSE Manager 3.2, see the 3.2 product documentation: https://www.suse.com/documentation/suse-manager-3/3.2/susemanager-best-practices/html/book.suma.best.practices/bp.sp.migration.html#sp.migration.postgresql. You cannot migrate directly from PostgreSQL 9.4 to version 10.

Prepare to Upgrade

Before you begin the upgrade, prepare your existing 3.2 system and create a database backup.

PostgreSQL stores data at /var/lib/pgsql/data/, and logs to /var/lib/pgsql/data/pg_xlog/.

Procedure: Preparing to Upgrade
  1. Check the active PostgreSQL version:

    psql --version

    If you are using PostgreSQL 9.6, you can upgrade to PostgreSQL 10.

  2. Check the active smdba version:

    rpm -q smdba

    PostgreSQL 10 requires smdba version 1.6.2 or later.

  3. Perform a database backup. For more information on backing up, see administration:backup-restore.adoc.

Upgrade PostgreSQL

Always create a database backup before performing a migration. For more information about a database backup, see Prepare to Upgrade.

PostgreSQL upgrades can be performed in two ways: a regular upgrade, or a fast upgrade:

A regular upgrade will create a complete copy of the database, so you will need double the existing database size of space available. Regular upgrades can take a considerable amount of time, depending on the size of the database and the speed of the storage system.

A fast upgrade only takes a few minutes, and uses almost no additional disk space. However, if a fast upgrade fails, you must restore the database from the backup. With the fast upgrade the risk to run out of disk space is smaller.

In case of failure you do not have the implicit backup that you get when doing a regular upgrade. The regular upgrade will copy the database files instead of hardlinking them.

Procedure: Performing a Regular Upgrade
  1. Perform a database backup. For more information on backing up, see administration:backup-restore.adoc.

  2. Begin the upgrade:

    /usr/lib/susemanager/bin/pg-migrate-96-to-10.sh
  3. When the upgrade has successfully completed, you can safely delete the old database directory and reclaim lost disk space. The old directory is renamed to /var/lib/pgsql/data-pg96.

The pg-migrate-96-to-10.sh script performs these operations:

  • Stop spacewalk services

  • Shut down the running database

  • Check if PostgreSQL 10 is installed and install it if necessary

  • Switch from PostgreSQL 9.6 to PostgreSQL 10 as the new default

  • Initiate the database migration

  • Create a PostgreSQL configuration file tuned for use by SUSE Manager

  • Start the database and spacewalk services

If the upgrade fails, the migration script will attempt to restore the database to its original state.

Procedure: Performing a Fast PostgreSQL Upgrade
  1. Perform a database backup. Without a verified database backup, you must not initiate a fast upgrade. For more information on backing up, see administration:backup-restore.adoc.

  2. Begin the upgrade:

    /usr/lib/susemanager/bin/pg-migrate-96-to-10.sh fast
  3. When the upgrade has successfully completed, you can safely delete the old database directory and reclaim lost disk space. The old directory is renamed to /var/lib/pgsql/data-pg96.