12.8. Migrating the Database


If you have installed Red Hat Satellite 5 but later need to transition your database, use the following sections to guide your migration process.

12.8.1. Migrating from an Embedded Database to a Managed Database

The requirements to migrate from Embedded to Managed Database are:
  • The Red Hat Satellite installation ISO
  • A complete installation of Red Hat Satellite server with an Embedded Database (satellite.example.com)
  • A new system to host the Managed Database with Red Hat Enterprise Linux 6 installed (manageddb.example.com)

Procedure 12.2. Migrating to a Managed Database

  1. Shut down the Red Hat Satellite instance:
    [root@satellite ~]# rhn-satellite stop
    
  2. Remove the rhn-upgrade package if it exists on your server:
    [root@satellite ~]# yum remove rhn-upgrade
    
  3. Use db-control to create a database backup
    [root@satellite ~]# mkdir ~/dbbackup
    [root@satellite ~]# db-control backup ~/dbbackup
    
  4. Copy the database backup from the Satellite server to the Managed Database server.
    [root@satellite ~]# scp -r ~/dbbackup root@manageddb.example.com:~/.
    
  5. Install the Managed Database using the Red Hat Satellite installation ISO.
  6. After you have installed the Managed External Database, shut it down and back up the database configuration and access control files.
    [root@manageddb ~]# db-control stop
    [root@manageddb ~]# cp /var/opt/rh/rh-postgresql95/lib/pgsql/data/postgresql.conf ~/dbbackup
    [root@manageddb ~]# cp /var/opt/rh/rh-postgresql95/lib/pgsql/data/pg_hba.conf ~/dbbackup
    
    You need to backup these files because the migration process will erase them.
  7. Use db-control to restore the database backup to the Managed Database server.
    [root@manageddb ~]# db-control restore ~/dbbackup
    
  8. Restore the database configuration and access control files from backup to the Managed Database.
    [root@manageddb ~]# cp ~/dbbackup/postgresql.conf /var/opt/rh/rh-postgresql95/lib/pgsql/data/postgresql.conf
    [root@manageddb ~]# cp ~/dbbackup/pg_hba.conf /var/opt/rh/rh-postgresql95/lib/pgsql/data/pg_hba.conf
    
  9. On the Satellite server, edit the /etc/rhn/rhn.conf file and change db_host to the domain name of the Managed Database and set the db_port to 5432. For example:
    db_host = manageddb.example.com
    db_port = 5432
    
  10. Remove rh-postgresql95-postgresql from the /etc/rhn/service-list file on the Satellite server.
    [root@satellite ~]# sed -i 's/rh-postgresql95-postgresql //g' /etc/rhn/service-list
    
  11. On the Managed Database, edit the /etc/rhn/rhn.conf file and change db_name, db_user, db_password to reflect the same values in /etc/rhn/rhn.conf on the Satellite server. For example:
    db_name = mydb
    db_user = mydbuser
    db_password = mydbpassword
    
  12. Start the Managed Database instance using db-control.
    [root@manageddb ~]# db-control start
    
  13. Remove the PostgreSQL and spacewalk-dobby packages from the Satellite server.
    [root@satellite ~]# yum remove rh-postgresql95 rh-postgresql95-postgresql rh-postgresql95-postgresql-contrib rh-postgresql95-postgresql-libs rh-postgresql95-postgresql-server rh-postgresql95-postgresql-pltcl spacewalk-dobby
    
  14. Restart Red Hat Satellite.
    [root@satellite ~]# rhn-satellite start
    
The database is now migrated from an Embedded Database to a Managed Database.

12.8.2. Migrating from an Embedded Database to an External PostgreSQL Database

The requirements to migrate from Embedded to an External PostgreSQL Database:

Procedure 12.3. Migrating to an External PostgreSQL Database

  1. Shut down all services on the Red Hat Satellite server, but start the Embedded Database with db-control:
    [root@satellite ~]# rhn-satellite stop
    [root@satellite ~]# db-control start
    
  2. Remove the rhn-upgrade if it exists on your server:
    [root@satellite ~]# yum remove rhn-upgrade
    
  3. Update your database to the latest schema version:
    [root@satellite ~]# yum update satellite-schema
    [root@satellite ~]# spacewalk-schema-upgrade
    
    This ensures that your database version matches the latest version on the External PostgreSQL Database.
  4. Create a directory to hold your database snapshot.
    [root@satellite ~]# mkdir ~/dbbackup
    [root@satellite ~]# cd ~/dbbackup
    
  5. Export the database using spacewalk-dump-schema:
    [root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
    
  6. Stop the Embedded Database:
    [root@satellite dbbackup]# db-control stop
    
  7. Use spacewalk-setup to populate the External PostgreSQL Database:
    [root@satellite dbbackup]# spacewalk-setup --db-only --external-postgresql
    
    The script asks for your database details so Satellite can connect and populate the database. Enter your External PostgreSQL Database details:
    ** Database: Setting up database connection for PostgreSQL backend.
    Hostname (leave empty for local)? postgresql.example.com
    Port [5432]?
    Database? myextdb
    Username? root
    Password?
    
    The script populates the database.
  8. When the script completes database population, restore the database schema
    [root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
    
  9. Remove the PostgreSQL and spacewalk-dobby packages from the Satellite server.
    [root@satellite ~]# yum remove rh-postgresql95 rh-postgresql95-postgresql rh-postgresql95-postgresql-contrib rh-postgresql95-postgresql-libs rh-postgresql95-postgresql-server rh-postgresql95-postgresql-pltcl spacewalk-dobby
    
  10. Start Red Hat Satellite.
    [root@satellite ~]# rhn-satellite start
    
The database is now migrated from an Embedded Database to an External PostgreSQL Database.

12.8.3. Migrating from an Embedded Database to an External Oracle Database

The requirements to migrate from Embedded to an External Oracle Database:
  • A complete installation of Red Hat Satellite server with an Embedded Database (satellite.example.com)
  • A system hosting a running instance of Oracle Database (oracledb.example.com). See Section 3.3.1, “External Database Requirements” for configuration details.

Procedure 12.4. Migrating to an External Oracle Database

  1. Shut down all services on the Red Hat Satellite server, but start the Embedded Database with db-control:
    [root@satellite ~]# rhn-satellite stop
    [root@satellite ~]# db-control start
    
  2. Remove the rhn-upgrade package if it exists on your server:
    [root@satellite ~]# yum remove rhn-upgrade
    
  3. Update your database to the latest schema version:
    [root@satellite ~]# yum update satellite-schema
    [root@satellite ~]# spacewalk-schema-upgrade
    
    This ensures that your database version matches the latest version on the External Oracle Database.
  4. Create a directory to hold your database snapshot.
    [root@satellite ~]# mkdir ~/dbbackup
    [root@satellite ~]# cd ~/dbbackup
    
  5. Export the database using spacewalk-dump-schema:
    [root@satellite dbbackup]# spacewalk-dump-schema --to=oracle > migrate-to-oracle.sql
    
  6. Stop the Embedded Database:
    [root@satellite dbbackup]# db-control stop
    
  7. Exchange the PostgreSQL drivers and configuration scripts with the Oracle drivers and configuration scripts on the Satellite server:
    [root@satellite dbbackup]# yum remove -y spacewalk-postgresql
    [root@satellite dbbackup]# yum install -y spacewalk-oracle
    [root@satellite dbbackup]# yum remove -y spacewalk-java-postgresql spacewalk-backend-sql-postgresql
    
  8. Use spacewalk-setup to populate the External Oracle Database:
    [root@satellite dbbackup]# spacewalk-setup --db-only --external-oracle
    
    The script asks for your database details so Satellite can connect and populate the database. Enter your External Oracle Database details:
    ** Database: Setting up database connection for Oracle backend.
    Database service name (SID)? oracledb
    Database hostname [localhost]? oracledb.example.com
    Database (listener) port [1521]?
    
    The script populates the database.

    Important

    Use the default Oracle Database port (1521) for the Red Hat Satellite database. Using an alternative port can cause SELinux errors.
  9. When the script completes database population, restore the database schema
    [root@satellite dbbackup]# spacewalk-sql -i < migrate-to-oracle.sql
    

    Important

    You might need to change SELinux context of the migration script before loading it into Oracle Database:
    [root@satellite dbbackup]# semanage fcontext -a -t oracle_sqlplus_exec_t /root/dbbackup/migrate-to-oracle.sql
    [root@satellite dbbackup]# restorecon -v /root/dbbackup/migrate-to-oracle.sql
    
    Similarly, you might need to change SELinux context of dumped tables:
    [root@satellite dbbackup]# semanage fcontext -a -t oracle_tmp_t "/tmp/dumped-tables(/.*)?"
    [root@satellite dbbackup]# restorecon -R -v /tmp/dumped-tables/
    
  10. Remove the PostgreSQL and spacewalk-dobby packages from the Satellite server.
    [root@satellite ~]# yum remove rh-postgresql95 rh-postgresql95-postgresql rh-postgresql95-postgresql-contrib rh-postgresql95-postgresql-libs rh-postgresql95-postgresql-server rh-postgresql95-postgresql-pltcl spacewalk-dobby
    
  11. Start Red Hat Satellite.
    [root@satellite ~]# rhn-satellite start
    
The database is now migrated from an Embedded Database to an External Oracle Database.

12.8.4. Migrating from a Managed Database to an Embedded Database

The requirements to migrate from Managed to Embedded Database are:
  • The Red Hat Satellite installation ISO
  • A complete installation of Red Hat Satellite server (satellite.example.com) with a Managed Database on a seperate server (manageddb.example.com)

Procedure 12.5. Migrating to an Embedded Database

  1. Stop the main services on the Satellite server.
    [root@satellite ~]# rhn-satellite stop
    
  2. Shut down the database on the Managed Database server.
    [root@manageddb ~]# db-control stop
    
  3. Remove the rhn-upgrade package if it exists on your server:
    [root@satellite ~]# yum remove rhn-upgrade
    
  4. Use db-control to create a database backup on the Managed Database Server and copy that backup to the Satellite server.
    [root@manageddb ~]# mkdir ~/dbbackup
    [root@manageddb ~]# db-control backup ~/dbbackup
    [root@manageddb ~]# scp -r ~/dbbackup root@satellite.example.com:~/.
    
    The Managed Database server is now free for other purposes. All further actions take place on the Satellite server.
  5. Mount the Red Hat Satellite installation ISO on the Satellite server and set and export the YUM0 variable with the Red Hat Satellite mount point value.
    [root@satellite ~]# mkdir /media/cdrom
    [root@satellite ~]# mount -o loop Red_Hat_Satellite_58.iso /media/cdrom
    [root@satellite ~]# export YUM0=/media/cdrom
    
  6. Enable the red-hat-satellite repository. If the red-hat-satellite repository definition is not present, install the satellite-repo package found in $YUM0/Satellite. After the red-hat-satellite repository is enabled, install the @satellite-database package group and disable the red-hat-satellite repository.
    [root@satellite ~]# yum install @satellite-database --enablerepo=red-hat-satellite
    
  7. Use db-control to restore the database backup.
    [root@satellite ~]# db-control restore ~/dbbackup
    
  8. Edit the /etc/rhn/rhn.conf file to remove the db_port and db_hostname values.
    [root@satellite ~]# sed -i 's/db_host\s*=.*/db_host = /' /etc/rhn/rhn.conf
    [root@satellite ~]# sed -i 's/db_port\s*=.*/db_port = /' /etc/rhn/rhn.conf
    
  9. Add the rh-postgresql95-postgresql service to the /etc/rhn/service-list file to ensure that it is started and stopped in parallel with Red Hat Satellite.
    [root@satellite ~]# echo "SERVICES=\"rh-postgresql95-postgresql \$SERVICES\"" >> /etc/rhn/service-list
    
  10. Start the Red Hat Satellite services.
    [root@satellite ~]# rhn-satellite start
    
The database is now migrated from a Managed Database to an Embedded Database.

12.8.5. Migrating from an External PostgreSQL Database to an Embedded Database

The requirements to migrate from an External PostgreSQL Database to an Embedded database:
  • A complete installation of Red Hat Satellite server (satellite.example.com) using an External PostgreSQL Database (postgresql.example.com).

Procedure 12.6. Migrating to an Embedded Database from an External PostgreSQL Database

  1. Shut down all services on the Red Hat Satellite server:
    [root@satellite ~]# rhn-satellite stop
    
  2. Make sure your External PostgreSQL Database is still running.
  3. Remove the rhn-upgrade if it exists on your server:
    [root@satellite ~]# yum remove rhn-upgrade
    
  4. Update the External PostgreSQL Database to the latest schema version:
    [root@satellite ~]# yum update satellite-schema
    [root@satellite ~]# spacewalk-schema-upgrade
    
    This ensures that your database version matches the latest version for the Embedded Database.
  5. Create a directory to hold your database snapshot.
    [root@satellite ~]# mkdir ~/dbbackup
    [root@satellite ~]# cd ~/dbbackup
    
  6. Export the database using spacewalk-dump-schema:
    [root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
    
  7. Stop the External Database. It is no longer required.
  8. Install the PostgreSQL installation and Satellite database tools packages on the Satellite server:
    [root@satellite dbbackup]# yum install -y spacewalk-setup-postgresql spacewalk-dobby
    
  9. Use spacewalk-setup to populate the Embedded Database:
    [root@satellite dbbackup]# spacewalk-setup --db-only
    
    The script populates the database. Wait until this process completes.
    ** Database: Setting up database connection for PostgreSQL backend.
    ** Database: Installing the database:
    ** Database: This is a long process that is logged in:
    ** Database:   /var/log/rhn/install_db.log
    *** Progress: #
    ** Database: Installation complete.
    ** Database: Populating database.
    *** Progress: ####################################
    
  10. When the script completes database population, restore the database schema:
    [root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
    
  11. Start Red Hat Satellite.
    [root@satellite ~]# rhn-satellite start
    
The database is now migrated from an External PostgreSQL Database to an Embedded Database.

12.8.6. Migrating from an External Oracle Database to an Embedded Database

The requirements to migrate from an External Oracle Database to an Embedded database:
  • A complete installation of Red Hat Satellite server (satellite.example.com) using an External Oracle Database (oracledb.example.com).

Procedure 12.7. Migrating to an Embedded Database from Oracle Database

  1. Shut down all services on the Red Hat Satellite server:
    [root@satellite ~]# rhn-satellite stop
    
  2. Make sure your External Oracle Database is still running.
  3. Remove the rhn-upgrade if it exists on your server:
    [root@satellite ~]# yum remove rhn-upgrade
    
  4. Update the External Oracle Database to the latest schema version:
    [root@satellite ~]# yum update satellite-schema
    [root@satellite ~]# spacewalk-schema-upgrade
    
    This ensures that your database version matches the latest version for the Embedded Database.
  5. Create a directory to hold your database snapshot.
    [root@satellite ~]# mkdir ~/dbbackup
    [root@satellite ~]# cd ~/dbbackup
    
  6. Export the database using spacewalk-dump-schema:
    [root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
    
  7. Stop the External Oracle Database. It is no longer required.
  8. Exchange the Oracle drivers and configuration scripts with the PostgreSQL drivers and configuration scripts on the Satellite server:
    [root@satellite dbbackup]# yum remove -y spacewalk-oracle
    [root@satellite dbbackup]# yum install -y spacewalk-postgresql spacewalk-setup-postgresql spacewalk-dobby
    [root@satellite dbbackup]# yum remove -y spacewalk-java-oracle spacewalk-backend-sql-oracle
    
  9. Use spacewalk-setup to populate the Embedded Database:
    [root@satellite dbbackup]# spacewalk-setup --db-only
    
    The script populates the database. Wait until this process completes.
    ** Database: Setting up database connection for PostgreSQL backend.
    ** Database: Installing the database:
    ** Database: This is a long process that is logged in:
    ** Database:   /var/log/rhn/install_db.log
    *** Progress: #
    ** Database: Installation complete.
    ** Database: Populating database.
    *** Progress: ####################################
    
  10. When the script completes database population, restore the database schema
    [root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
    
  11. Start Red Hat Satellite.
    [root@satellite ~]# rhn-satellite start
    
The database is now migrated from an External Oracle Database to an Embedded Database.

12.8.7. Migrating from an External Oracle Database to an External PostgreSQL Database

The requirements to migrate from an External Oracle Database to an External PostgreSQL database:
  • A complete installation of Red Hat Satellite server (satellite.example.com) using an External Oracle Database (oracledb.example.com).
  • A system hosting a running instance of PostgreSQL (postgresql.example.com), See Section 3.3.1.1, “PostgreSQL Database Requirements” for configuration details.

Procedure 12.8. Migrating to an External Database from Oracle Database

  1. Shut down all services on the Red Hat Satellite server:
    [root@satellite ~]# rhn-satellite stop
    
  2. Make sure your External Oracle Database is still running.
  3. Remove the rhn-upgrade if it exists on your server:
    [root@satellite ~]# yum remove rhn-upgrade
    
  4. Update the External Oracle Database to the latest schema version:
    [root@satellite ~]# yum update satellite-schema
    [root@satellite ~]# spacewalk-schema-upgrade
    
    This ensures that your database version matches the latest version for the External Database.
  5. Create a directory to hold your database snapshot.
    [root@satellite ~]# mkdir ~/dbbackup
    [root@satellite ~]# cd ~/dbbackup
    
  6. Export the database using spacewalk-dump-schema:
    [root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
    
  7. Stop the External Oracle Database. It is no longer required.
  8. Exchange the Oracle drivers and configuration scripts with the PostgreSQL drivers and configuration scripts on the Satellite server:
    [root@satellite dbbackup]# yum remove -y spacewalk-oracle
    [root@satellite dbbackup]# yum install -y spacewalk-postgresql
    [root@satellite dbbackup]# yum remove -y spacewalk-java-oracle spacewalk-backend-sql-oracle
    
  9. Use spacewalk-setup to populate the External Database:
    [root@satellite dbbackup]# spacewalk-setup --db-only --external-postgresql
    
    The script asks for your database details so Satellite can connect and populate the database. Enter your External PostgreSQL Database details:
    ** Database: Setting up database connection for PostgreSQL backend.
    Hostname (leave empty for local)? postgresql.example.com
    Port [5432]?
    Database? myextdb
    Username? root
    Password?
    
  10. When the script completes database population, restore the database schema
    [root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
    
  11. Start Red Hat Satellite.
    [root@satellite ~]# rhn-satellite start
    
The database is now migrated from an External Oracle Database to an External PostgreSQL Database.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.