Chapter 9. Migrating Databases
9.1. Migrating the Self-Hosted Engine Database to a Remote Server Database
enginedatabase of a self-hosted engine to a remote database server after the Red Hat Enterprise Virtualization Manager has been initially configured.
pg_restorecommands to handle the database backup and restore. As such, it is necessary to edit the
/etc/ovirt-engine/engine.conf.d/10-setup-database.conffile with the updated information. At a minimum, you must update the location of the new database server. If the database name, role name, or password are modified for the new database server, these values must also be updated in the
10-setup-database.conffile. This procedure uses the default
enginedatabase settings to minimize modification of this file.
Procedure 9.1. Preparing the Remote PostgreSQL Database for use with the Red Hat Enterprise Virtualization Manager
- Log in to the remote database server and install the PostgreSQL server package:
# yum install postgresql-server
- Initialize the PostgreSQL database, start the
postgresqlservice, and ensure that this service starts on boot:
# service postgresql initdb # service postgresql start # chkconfig postgresql on
- Connect to the psql command line interface as the
# su - postgres $ psql
- Create a user for the Manager to use when it writes to and reads from the database. The default user name on the Manager is
postgres=# create role user_name with login encrypted password 'password';
NoteThe password for the
engineuser is located in plain text in
/etc/ovirt-engine/engine.conf.d/10-setup-database.conf. Any password can be used when creating the role on the new server, however if a different password is used then this file must be updated with the new password.
- Create a database in which to store data about the Red Hat Enterprise Virtualization environment. The default database name on the Manager is
engine, and the default user name is
postgres=# create database database_name owner user_name template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
- Ensure the database can be accessed remotely by enabling md5 client authentication. Edit the
/var/lib/pgsql/data/pg_hba.conffile, and add the following line immediately underneath the line starting with
localat the bottom of the file, replacing X.X.X.X with the IP address of the Manager:
host database_name user_name X.X.X.X/32 md5
- Allow TCP/IP connections to the database. Edit the
/var/lib/pgsql/data/postgresql.conffile and add the following line:
listen_addresses='*'This example configures the
postgresqlservice to listen for connections on all interfaces. You can specify an interface by giving its IP address.
- Open the default port used for PostgreSQL database connections, and save the updated firewall rules:
# iptables -I INPUT 5 -p tcp --dport 5432 -j ACCEPT # service iptables save
- Restart the
# service postgresql restart
Procedure 9.2. Migrating the Database
- Log in to one of the hosted-engine hosts and place the environment into
globalmaintenance mode. This disables the High Availability agents and prevents the Manager virtual machine from being migrated occurring during the procedure:
# hosted-engine --set-maintenance --mode=global
- Log in to the Manager virtual machine and stop the
ovirt-engineservice so that it does not interfere with the engine backup:
# service ovirt-engine stop
- Create the
enginedatabase backup using the PostgreSQL
# su - postgres -c 'pg_dump -F c engine -f /tmp/engine.dump'
- Copy the backup file to the new database server. The target directory must allow write access for the
# scp /tmp/engine.dump firstname.lastname@example.org:/tmp/engine.dump
- Log in to the new database server and restore the database using the PostgreSQL
# su - postgres -c 'pg_restore -d engine /tmp/engine.dump'
- Log in to the Manager virtual machine and update the
/etc/ovirt-engine/engine.conf.d/10-setup-database.confand replace the
ENGINE_DB_HOSTwith the IP address of the new database server. If the engine name, role name, or password differ on the new database server, update those values in this file.
- Now that the database has been migrated, start the
# service ovirt-engine start
- Log in to a hosted-engine host and turn off maintenance mode, enabling the High Availability agents:
# hosted-engine --set-maintenance --mode=none