Database Migration
When you installed SUSE Manager Server 3.1 or earlier on SUSE Linux Enterprise Server 12 SP2 or earlier, it was based on a PostgreSQL 9.4 database. PostgreSQL 9.4 can be upgraded to PostgreSQL 9.6.
SUSE Manager 3 uses PostgreSQL 9.4 by default. SUSE Linux Enterprise Server 12 SP3 uses PostgreSQL 9.6 by default.
This chapter provides information on managing your PostgreSQL database, and provides instructions for upgrading your database to PostgreSQL 9.6.
SUSE Manager 3.1 on SUSE Linux Enterprise Server 12 SP3 and SUSE Manager 3.2 use PostgreSQL 9.6 by default. If you use one of those you can skip this section.
Prepare to Upgrade
Before you begin the upgrade, prepare your existing system and create a database backup.
PostgreSQL stores data at /var/lib/pgsql/data/
, and logs to /var/lib/pgsql/data/pg_xlog/
.
-
Check the active PostgreSQL version:
psql --version
If you are using PostgreSQL 9.4, you can upgrade to PostgreSQL 9.6.
-
Check the active smdba version:
rpm -q smdba
PostgreSQL 9.6 requires smdba version 1.5.8 or later.
-
Perform a database backup. For more information on backing up, see administration:backup-restore.adoc.
Always create a database backup before performing a migration. |
Upgrade PostgreSQL
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. Regular upgrades also require database downtime, your database will not be accessible while the upgrade is running.
A fast upgrade only takes a few minutes, and uses no additional disk space. However, fast upgrades are more likely to fail, and if this occurs you will need to restore the database from backup.
-
Perform a database backup. For more information on backing up, see administration:backup-restore.adoc.
-
Begin the upgrade:
/usr/lib/susemanager/bin/pg-migrate.sh
-
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-pg94
.
The pg-migrate.sh
script performs these operations:
-
Stop spacewalk services
-
Shut down the running database
-
Check if PostgreSQL 9.6 is installed and install it if necessary
-
Switch from PostgreSQL 9.4 to PostgreSQL 9.6 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. |
-
Perform a database backup. For more information on backing up, see administration:backup-restore.adoc.
-
Begin the upgrade:
/usr/lib/susemanager/bin/pg-migrate.sh fast
-
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-pg94
.