12.8. Migrating the Database
12.8.1. Migrating from an Embedded Database to a Managed Database
- 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
- Shut down the Red Hat Satellite instance:
[root@satellite ~]# rhn-satellite stop
- Remove the
rhn-upgrade
package if it exists on your server:[root@satellite ~]# yum remove rhn-upgrade
- Use
db-control
to create a database backup[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# db-control backup ~/dbbackup
- Copy the database backup from the Satellite server to the Managed Database server.
[root@satellite ~]# scp -r ~/dbbackup root@manageddb.example.com:~/.
- Install the Managed Database using the Red Hat Satellite installation ISO.
- 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. - Use
db-control
to restore the database backup to the Managed Database server.[root@manageddb ~]# db-control restore ~/dbbackup
- 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
- On the Satellite server, edit the
/etc/rhn/rhn.conf
file and changedb_host
to the domain name of the Managed Database and set thedb_port
to 5432. For example:db_host = manageddb.example.com db_port = 5432
- 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
- On the Managed Database, edit the
/etc/rhn/rhn.conf
file and changedb_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
- Start the Managed Database instance using
db-control
.[root@manageddb ~]# db-control start
- 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
- Restart Red Hat Satellite.
[root@satellite ~]# rhn-satellite start
12.8.2. Migrating from an Embedded Database to an External PostgreSQL Database
- A complete installation of Red Hat Satellite server with an Embedded Database (
satellite.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.3. Migrating to an External PostgreSQL Database
- 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
- Remove the
rhn-upgrade
if it exists on your server:[root@satellite ~]# yum remove rhn-upgrade
- 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. - Create a directory to hold your database snapshot.
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
- Export the database using
spacewalk-dump-schema
:[root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
- Stop the Embedded Database:
[root@satellite dbbackup]# db-control stop
- 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. - When the script completes database population, restore the database schema
[root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
- 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
- Start Red Hat Satellite.
[root@satellite ~]# rhn-satellite start
12.8.3. Migrating from an Embedded Database 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
- 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
- Remove the
rhn-upgrade
package if it exists on your server:[root@satellite ~]# yum remove rhn-upgrade
- 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. - Create a directory to hold your database snapshot.
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
- Export the database using
spacewalk-dump-schema
:[root@satellite dbbackup]# spacewalk-dump-schema --to=oracle > migrate-to-oracle.sql
- Stop the Embedded Database:
[root@satellite dbbackup]# db-control stop
- 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
- 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. - 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/
- 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
- Start Red Hat Satellite.
[root@satellite ~]# rhn-satellite start
12.8.4. Migrating from a Managed Database to an Embedded Database
- 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
- Stop the main services on the Satellite server.
[root@satellite ~]# rhn-satellite stop
- Shut down the database on the Managed Database server.
[root@manageddb ~]# db-control stop
- Remove the
rhn-upgrade
package if it exists on your server:[root@satellite ~]# yum remove rhn-upgrade
- 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. - 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
- Enable the
red-hat-satellite
repository. If thered-hat-satellite
repository definition is not present, install thesatellite-repo
package found in$YUM0/Satellite
. After thered-hat-satellite
repository is enabled, install the@satellite-database
package group and disable thered-hat-satellite
repository.[root@satellite ~]# yum install @satellite-database --enablerepo=red-hat-satellite
- Use
db-control
to restore the database backup.[root@satellite ~]# db-control restore ~/dbbackup
- 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
- 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
- Start the Red Hat Satellite services.
[root@satellite ~]# rhn-satellite start
12.8.5. Migrating 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
- Shut down all services on the Red Hat Satellite server:
[root@satellite ~]# rhn-satellite stop
- Make sure your External PostgreSQL Database is still running.
- Remove the
rhn-upgrade
if it exists on your server:[root@satellite ~]# yum remove rhn-upgrade
- 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. - Create a directory to hold your database snapshot.
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
- Export the database using
spacewalk-dump-schema
:[root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
- Stop the External Database. It is no longer required.
- Install the PostgreSQL installation and Satellite database tools packages on the Satellite server:
[root@satellite dbbackup]# yum install -y spacewalk-setup-postgresql spacewalk-dobby
- 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: ####################################
- When the script completes database population, restore the database schema:
[root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
- Start Red Hat Satellite.
[root@satellite ~]# rhn-satellite start
12.8.6. Migrating 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
- Shut down all services on the Red Hat Satellite server:
[root@satellite ~]# rhn-satellite stop
- Make sure your External Oracle Database is still running.
- Remove the
rhn-upgrade
if it exists on your server:[root@satellite ~]# yum remove rhn-upgrade
- 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. - Create a directory to hold your database snapshot.
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
- Export the database using
spacewalk-dump-schema
:[root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
- Stop the External Oracle Database. It is no longer required.
- 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
- 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: ####################################
- When the script completes database population, restore the database schema
[root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
- Start Red Hat Satellite.
[root@satellite ~]# rhn-satellite start
12.8.7. Migrating 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
- Shut down all services on the Red Hat Satellite server:
[root@satellite ~]# rhn-satellite stop
- Make sure your External Oracle Database is still running.
- Remove the
rhn-upgrade
if it exists on your server:[root@satellite ~]# yum remove rhn-upgrade
- 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. - Create a directory to hold your database snapshot.
[root@satellite ~]# mkdir ~/dbbackup [root@satellite ~]# cd ~/dbbackup
- Export the database using
spacewalk-dump-schema
:[root@satellite dbbackup]# spacewalk-dump-schema --to=postgresql > migrate-to-postgresql.sql
- Stop the External Oracle Database. It is no longer required.
- 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
- 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?
- When the script completes database population, restore the database schema
[root@satellite dbbackup]# spacewalk-sql -i < migrate-to-postgresql.sql
- Start Red Hat Satellite.
[root@satellite ~]# rhn-satellite start