Chapter 3. Migrating from Internal Satellite Databases to External Databases
When you install Red Hat Satellite, the satellite-installer command installs PostgreSQL databases on the same server as Satellite. If you are using the default internal databases but want to start using external databases to help with the server load, you can migrate your internal databases to external databases.
To confirm whether your Satellite Server has internal or external databases, you can query the status of your databases:
For PostgreSQL, enter the following command:
satellite-maintain service status --only postgresql
# satellite-maintain service status --only postgresql
Red Hat does not provide support or tools for external database maintenance. This includes backups, upgrades, and database tuning. You must have your own database administrator to support and maintain external databases.
To migrate from the default internal databases to external databases, you must complete the following procedures:
- Section 3.2, “Preparing a Host for External Databases”. Prepare a Red Hat Enterprise Linux 8 or Red Hat Enterprise Linux 7 server to host the external databases.
- Section 3.3, “Installing PostgreSQL”. Prepare PostgreSQL with databases for Satellite, Pulp and Candlepin with dedicated users owning them.
-
Section 3.4, “Migrating to External Databases”. Edit the parameters of
satellite-installer
to point to the new databases, and runsatellite-installer
.
3.1. PostgreSQL as an External Database Considerations
Foreman, Katello, and Candlepin use the PostgreSQL database. If you want to use PostgreSQL as an external database, the following information can help you decide if this option is right for your Satellite configuration. Satellite supports PostgreSQL version 12.
Advantages of External PostgreSQL:
- Increase in free memory and free CPU on Satellite
-
Flexibility to set
shared_buffers
on the PostgreSQL database to a high number without the risk of interfering with other services on Satellite - Flexibility to tune the PostgreSQL server’s system without adversely affecting Satellite operations
Disadvantages of External PostgreSQL
- Increase in deployment complexity that can make troubleshooting more difficult
- The external PostgreSQL server is an additional system to patch and maintain
- If either Satellite or the PostgreSQL database server suffers a hardware or storage failure, Satellite is not operational
- If there is latency between the Satellite server and database server, performance can suffer
If you suspect that the PostgreSQL database on your Satellite is causing performance problems, use the information in Satellite 6: How to enable postgres query logging to detect slow running queries to determine if you have slow queries. Queries that take longer than one second are typically caused by performance issues with large installations, and moving to an external database might not help. If you have slow queries, contact Red Hat Support.
3.2. Preparing a Host for External Databases
Install a freshly provisioned system with the latest Red Hat Enterprise Linux 8 or Red Hat Enterprise Linux 7 server to host the external databases.
Subscriptions for Red Hat Software Collections and Red Hat Enterprise Linux do not provide the correct service level agreement for using Satellite with external databases. You must also attach a Satellite subscription to the base operating system that you want to use for the external databases.
Prerequisites
- The prepared host must meet Satellite’s Storage Requirements.
Procedure
- Use the instructions in Attaching the Satellite Infrastructure Subscription to attach a Satellite subscription to your server.
Disable all repositories and enable only the following repositories:
For Red Hat Enterprise Linux 7:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow subscription-manager repos --disable '*' subscription-manager repos --enable=rhel-server-rhscl-7-rpms \ --enable=rhel-7-server-rpms --enable=rhel-7-server-satellite-6.11-rpms
# subscription-manager repos --disable '*' # subscription-manager repos --enable=rhel-server-rhscl-7-rpms \ --enable=rhel-7-server-rpms --enable=rhel-7-server-satellite-6.11-rpms
For Red Hat Enterprise Linux 8:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow subscription-manager repos --disable '*' subscription-manager repos \ --enable=satellite-6.11-for-rhel-8-x86_64-rpms \ --enable=rhel-8-for-x86_64-baseos-rpms \ --enable=rhel-8-for-x86_64-appstream-rpms
# subscription-manager repos --disable '*' # subscription-manager repos \ --enable=satellite-6.11-for-rhel-8-x86_64-rpms \ --enable=rhel-8-for-x86_64-baseos-rpms \ --enable=rhel-8-for-x86_64-appstream-rpms
On Red Hat Enterprise Linux 8, enable the following modules:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow dnf module enable satellite:el8
# dnf module enable satellite:el8
NoteEnablement of the module
satellite:el8
warns about a conflict withpostgresql:10
andruby:2.5
as these modules are set to the default module versions on Red Hat Enterprise Linux 8. The modulesatellite:el8
has a dependency for the modulespostgresql:12
andruby:2.7
that will be enabled with thesatellite:el8
module. These warnings do not cause installation process failure, hence can be ignored safely. For more information about modules and lifecycle streams on Red Hat Enterprise Linux 8, see Red Hat Enterprise Linux Application Streams Life Cycle.
3.3. Installing PostgreSQL
You can install only the same version of PostgreSQL that is installed with the satellite-installer
tool during an internal database installation. You can install PostgreSQL using Red Hat Enterprise Linux 8 or Red Hat Enterprise Linux Server 7 repositories. Satellite supports PostgreSQL version 12.
3.3.1. Installing PostgreSQL on Red Hat Enterprise Linux 8
Procedure
To install PostgreSQL, enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow dnf install postgresql-server postgresql-evr
# dnf install postgresql-server postgresql-evr
To initialize PostgreSQL, enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow postgresql-setup initdb
# postgresql-setup initdb
Edit the
/var/lib/pgsql/data/postgresql.conf
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow vi /var/lib/pgsql/data/postgresql.conf
# vi /var/lib/pgsql/data/postgresql.conf
Remove the
#
and edit to listen to inbound connections:Copy to Clipboard Copied! Toggle word wrap Toggle overflow listen_addresses = '*'
listen_addresses = '*'
Edit the
/var/lib/pgsql/data/pg_hba.conf
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow vi /var/lib/pgsql/data/pg_hba.conf
# vi /var/lib/pgsql/data/pg_hba.conf
Add the following line to the file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow host all all Satellite_ip/24 md5
host all all Satellite_ip/24 md5
To start, and enable PostgreSQL service, enter the following commands:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow systemctl start postgresql systemctl enable postgresql
# systemctl start postgresql # systemctl enable postgresql
Open the postgresql port on the external PostgreSQL server:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow firewall-cmd --add-service=postgresql firewall-cmd --runtime-to-permanent
# firewall-cmd --add-service=postgresql # firewall-cmd --runtime-to-permanent
Switch to the
postgres
user and start the PostgreSQL client:Copy to Clipboard Copied! Toggle word wrap Toggle overflow su - postgres -c psql
$ su - postgres -c psql
Create three databases and dedicated roles: one for Satellite, one for Candlepin, and one for Pulp:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow CREATE USER "foreman" WITH PASSWORD 'Foreman_Password'; CREATE USER "candlepin" WITH PASSWORD 'Candlepin_Password'; CREATE USER "pulp" WITH PASSWORD 'Pulpcore_Password'; CREATE DATABASE foreman OWNER foreman; CREATE DATABASE candlepin OWNER candlepin; CREATE DATABASE pulpcore OWNER pulp;
CREATE USER "foreman" WITH PASSWORD 'Foreman_Password'; CREATE USER "candlepin" WITH PASSWORD 'Candlepin_Password'; CREATE USER "pulp" WITH PASSWORD 'Pulpcore_Password'; CREATE DATABASE foreman OWNER foreman; CREATE DATABASE candlepin OWNER candlepin; CREATE DATABASE pulpcore OWNER pulp;
Exit the
postgres
user:Copy to Clipboard Copied! Toggle word wrap Toggle overflow \q
# \q
From Satellite Server, test that you can access the database. If the connection succeeds, the commands return
1
.Copy to Clipboard Copied! Toggle word wrap Toggle overflow PGPASSWORD='Foreman_Password' psql -h postgres.example.com -p 5432 -U foreman -d foreman -c "SELECT 1 as ping" PGPASSWORD='Candlepin_Password' psql -h postgres.example.com -p 5432 -U candlepin -d candlepin -c "SELECT 1 as ping" PGPASSWORD='Pulpcore_Password' psql -h postgres.example.com -p 5432 -U pulp -d pulpcore -c "SELECT 1 as ping"
# PGPASSWORD='Foreman_Password' psql -h postgres.example.com -p 5432 -U foreman -d foreman -c "SELECT 1 as ping" # PGPASSWORD='Candlepin_Password' psql -h postgres.example.com -p 5432 -U candlepin -d candlepin -c "SELECT 1 as ping" # PGPASSWORD='Pulpcore_Password' psql -h postgres.example.com -p 5432 -U pulp -d pulpcore -c "SELECT 1 as ping"
3.3.2. Installing PostgreSQL on Red Hat Enterprise Linux 7
Procedure
To install PostgreSQL, enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow yum install rh-postgresql12-postgresql-server \ rh-postgresql12-syspaths \ rh-postgresql12-postgresql-evr
# yum install rh-postgresql12-postgresql-server \ rh-postgresql12-syspaths \ rh-postgresql12-postgresql-evr
To initialize PostgreSQL, enter the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow postgresql-setup initdb
# postgresql-setup initdb
Edit the
/var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf
# vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf
Remove the
#
and edit to listen to inbound connections:Copy to Clipboard Copied! Toggle word wrap Toggle overflow listen_addresses = '*'
listen_addresses = '*'
Edit the
/var/opt/rh/rh-postgresql12/lib/pgsql/data/pg_hba.conf
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/pg_hba.conf
# vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/pg_hba.conf
Add the following line to the file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow host all all Satellite_ip/24 md5
host all all Satellite_ip/24 md5
To start, and enable PostgreSQL service, enter the following commands:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow systemctl start postgresql systemctl enable postgresql
# systemctl start postgresql # systemctl enable postgresql
Open the postgresql port on the external PostgreSQL server:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow firewall-cmd --add-service=postgresql firewall-cmd --runtime-to-permanent
# firewall-cmd --add-service=postgresql # firewall-cmd --runtime-to-permanent
Switch to the
postgres
user and start the PostgreSQL client:Copy to Clipboard Copied! Toggle word wrap Toggle overflow su - postgres -c psql
$ su - postgres -c psql
Create three databases and dedicated roles: one for Satellite, one for Candlepin, and one for Pulp:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow CREATE USER "foreman" WITH PASSWORD 'Foreman_Password'; CREATE USER "candlepin" WITH PASSWORD 'Candlepin_Password'; CREATE USER "pulp" WITH PASSWORD 'Pulpcore_Password'; CREATE DATABASE foreman OWNER foreman; CREATE DATABASE candlepin OWNER candlepin; CREATE DATABASE pulpcore OWNER pulp;
CREATE USER "foreman" WITH PASSWORD 'Foreman_Password'; CREATE USER "candlepin" WITH PASSWORD 'Candlepin_Password'; CREATE USER "pulp" WITH PASSWORD 'Pulpcore_Password'; CREATE DATABASE foreman OWNER foreman; CREATE DATABASE candlepin OWNER candlepin; CREATE DATABASE pulpcore OWNER pulp;
Exit the
postgres
user:Copy to Clipboard Copied! Toggle word wrap Toggle overflow \q
# \q
From Satellite Server, test that you can access the database. If the connection succeeds, the commands return
1
.Copy to Clipboard Copied! Toggle word wrap Toggle overflow PGPASSWORD='Foreman_Password' psql -h postgres.example.com -p 5432 -U foreman -d foreman -c "SELECT 1 as ping" PGPASSWORD='Candlepin_Password' psql -h postgres.example.com -p 5432 -U candlepin -d candlepin -c "SELECT 1 as ping" PGPASSWORD='Pulpcore_Password' psql -h postgres.example.com -p 5432 -U pulp -d pulpcore -c "SELECT 1 as ping"
# PGPASSWORD='Foreman_Password' psql -h postgres.example.com -p 5432 -U foreman -d foreman -c "SELECT 1 as ping" # PGPASSWORD='Candlepin_Password' psql -h postgres.example.com -p 5432 -U candlepin -d candlepin -c "SELECT 1 as ping" # PGPASSWORD='Pulpcore_Password' psql -h postgres.example.com -p 5432 -U pulp -d pulpcore -c "SELECT 1 as ping"
3.4. Migrating to External Databases
Back up and transfer existing data, then use the satellite-installer
command to configure Satellite to connect to an external PostgreSQL database server.
Prerequisites
- You have installed and configured a PostgreSQL server on a Red Hat Enterprise Linux server.
Procedure
On Satellite Server, stop Satellite services:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow satellite-maintain service stop
# satellite-maintain service stop
Start the PostgreSQL services:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow systemctl start postgresql
# systemctl start postgresql
Back up the internal databases:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow satellite-maintain backup online --skip-pulp-content --preserve-directory -y /var/migration_backup
# satellite-maintain backup online --skip-pulp-content --preserve-directory -y /var/migration_backup
Transfer the data to the new external databases:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow PGPASSWORD='Foreman_Password' pg_restore -h postgres.example.com -U foreman -d foreman < /var/migration_backup/foreman.dump PGPASSWORD='Candlepin_Password' pg_restore -h postgres.example.com -U candlepin -d candlepin < /var/migration_backup/candlepin.dump PGPASSWORD='Pulpcore_Password' pg_restore -h postgres.example.com -U pulp -d pulpcore < /var/migration_backup/pulpcore.dump
PGPASSWORD='Foreman_Password' pg_restore -h postgres.example.com -U foreman -d foreman < /var/migration_backup/foreman.dump PGPASSWORD='Candlepin_Password' pg_restore -h postgres.example.com -U candlepin -d candlepin < /var/migration_backup/candlepin.dump PGPASSWORD='Pulpcore_Password' pg_restore -h postgres.example.com -U pulp -d pulpcore < /var/migration_backup/pulpcore.dump
Use the
satellite-installer
command to update Satellite to point to the new databases:Copy to Clipboard Copied! Toggle word wrap Toggle overflow satellite-installer --scenario satellite \ --foreman-db-host postgres.example.com \ --foreman-db-password Foreman_Password \ --foreman-db-database foreman \ --foreman-db-manage false \ --foreman-db-username foreman \ --katello-candlepin-db-host postgres.example.com \ --katello-candlepin-db-name candlepin \ --katello-candlepin-db-password Candlepin_Password \ --katello-candlepin-manage-db false \ --katello-candlepin-db-user candlepin \ --foreman-proxy-content-pulpcore-manage-postgresql false \ --foreman-proxy-content-pulpcore-postgresql-host postgres.example.com \ --foreman-proxy-content-pulpcore-postgresql-db-name pulpcore \ --foreman-proxy-content-pulpcore-postgresql-password Pulpcore_Password \ --foreman-proxy-content-pulpcore-postgresql-user pulp
satellite-installer --scenario satellite \ --foreman-db-host postgres.example.com \ --foreman-db-password Foreman_Password \ --foreman-db-database foreman \ --foreman-db-manage false \ --foreman-db-username foreman \ --katello-candlepin-db-host postgres.example.com \ --katello-candlepin-db-name candlepin \ --katello-candlepin-db-password Candlepin_Password \ --katello-candlepin-manage-db false \ --katello-candlepin-db-user candlepin \ --foreman-proxy-content-pulpcore-manage-postgresql false \ --foreman-proxy-content-pulpcore-postgresql-host postgres.example.com \ --foreman-proxy-content-pulpcore-postgresql-db-name pulpcore \ --foreman-proxy-content-pulpcore-postgresql-password Pulpcore_Password \ --foreman-proxy-content-pulpcore-postgresql-user pulp