3.13. Migrating the Data Warehouse Database to a Remote Server Database
You can migrate the
ovirt_engine_history database to a remote database server after the Red Hat Enterprise Virtualization Manager has been initially configured.
This task is split into two procedures. The first procedure, preparing the remote PostgreSQL database, is a necessary prerequisite for the migration itself and presumes that the server has Red Hat Enterprise Linux installed and has been configured with the appropriate subscriptions.
The second procedure, migrating the database, uses PostgreSQL
pg_dump and pg_restore commands to handle the database backup and restore. As such, it is necessary to edit the /etc/ovirt-engine-reports/ovirt-engine-reports.conf.d/10-setup-database.conf and /etc/ovirt-engine-dwh/ovirt-engine-dwhd.conf.d/10-setup-database.conf files 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 both 10-setup-database.conf files. This procedure uses the default ovirt_engine_history database settings to minimize modification of this file.
Procedure 3.17. 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
postgresuser:# su - postgres $ psql
- Create a user for the Manager to use when it writes to and reads from the database. The default user name for the
ovirt_engine_historydatabase isovirt_engine_history:postgres=# create role user_name with login encrypted password 'password';
Note
The password for theovirt_engine_historyuser is located in plain text in/etc/ovirt-engine-dwh/ovirt-engine-dwhd.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, and the/etc/ovirt-engine-reports/ovirt-engine-reports.conf.d/10-setup-database.conffile, must be updated with the new password. - Create a database in which to store the history of the Red Hat Enterprise Virtualization environment. The default database name is
ovirt_engine_history, and the default user name isovirt_engine_history: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 withlocalat 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 thepostgresqlservice 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
postgresqlservice:# service postgresql restart
Optionally, set up SSL to secure database connections using the instructions at http://www.postgresql.org/docs/8.4/static/ssl-tcp.html#SSL-FILE-USAGE.
Procedure 3.18. Migrating the Database
- Log in to one of the hosted-engine hosts and place the environment into
globalmaintenance mode so that the High Availability agents do not interfere with the Manager virtual machine during the database migration:# hosted-engine --set-maintenance --mode=global
- Log in to the Red Hat Enterprise Virtualization Manager machine and stop the
ovirt-engine-dwhdservice so that it does not interfere with the engine backup:# service ovirt-engine-dwhd stop
- Create the
ovirt_engine_historydatabase backup using the PostgreSQLpg_dumpcommand:# su - postgres -c 'pg_dump -F c ovirt_engine_history -f /tmp/ovirt_engine_history.dump'
- Copy the backup file to the new database server. The target directory must allow write access for the
postgresuser:# scp /tmp/ovirt_engine_history.dump root@new.database.server.com:/tmp/ovirt_engine_history.dump
- Log in to the new database server and restore the database using the PostgreSQL
pg_restorecommand:# su - postgres -c 'pg_restore -d ovirt_engine_history /tmp/ovirt_engine_history.dump'
- Log in to the Manager server and update the
/etc/ovirt-engine-reports/ovirt-engine-reports.conf.d/10-setup-database.confand/etc/ovirt-engine-dwh/ovirt-engine-dwhd.conf.d/10-setup-database.conffiles, replacing thelocalhostvalue ofDWH_DB_HOSTwith the IP address of the new database server. If theDWH_DB_DATABASE,DWH_DB_USER, orDWH_DB_PASSWORDdiffer on the new database server, update those values in these files.If the Manager database has also been migrated, these values must also be updated in the/etc/ovirt-engine-dwh/ovirt-engine-dwhd.conf.d/10-setup-database.conffile. - Use a web browser to log in to the Reports portal atusing the
https://hostname.example.com/ovirt-engine-reports
superuseruser name. Click → to open the Folders side pane. - In the Folders side pane, select → → → .
- Select oVirt History and click .
- Update the Host (required) field with the IP address of the new database server and click .
- Now that the database has been migrated and the Reports portal connects to it, start the
ovirt-engine-dwhdservice:# service ovirt-engine-dwhd start
- Log in to a hosted-engine host and turn off maintenance mode, enabling the High Availability agents:
# hosted-engine --set-maintenance --mode=none