Databases

Oracle Linux Virtualization Manager creates a PostgreSQL database called engine during installation. Optionally, you might have the ovirt_engine_history database if you installed the data warehouse.

Occasionally, you should perform maintenance on these databases. Running the Engine Vacuum tool updates tables and removes dead rows, allowing disk space to be reused.

Reclaiming Database Storage

To reclaim database storage using the Engine Vacuum tool, you must log into the engine host as the root user and provide the administration credentials for the oVirt environment.

  1. Check the current database size:
    # /usr/share/ovirt-engine/dbscripts/engine-psql.sh -c "SELECT datname as db_name, pg_size_pretty(pg_database_size(datname)) as db_usage FROM pg_database"
  2. Vacuum the Engine database.
    1. Stop the ovirt-engine, ovirt-engine-dwhd, and grafana-server services:
      # systemctl stop ovirt-engine ovirt-engine-dwhd grafana-server
    2. Backup the engine database:
      # grep 'ENGINE_DB_PASSWORD=' /etc/ovirt-engine/engine.conf.d/10-setup-database.conf
      
      # PGPASSWORD=your-engine-db-pw /usr/bin/pg_dump \
       -E UTF8 \
       --disable-dollar-quoting \
       --disable-triggers \
       -U engine \
       -h localhost \
       -p 5432 \
       --format=custom \
       --file=/var/lib/ovirt-engine/backups/engine-$(date +%Y%m%d%H%M%S).$$.dump engine
    3. Vacuum the engine database:
      /usr/share/ovirt-engine/bin/engine-vacuum.sh -f -v
    4. Start the ovirt-engine, ovirt-engine-dwhd, and grafana-server services:
      # systemctl start ovirt-engine ovirt-engine-dwhd grafana-server
  3. Vacuum the data warehouse (ovirt_engine_history) database.
    1. Stop the ovirt-engine, ovirt-engine-dwhd, and grafana-server services:
      # systemctl stop ovirt-engine ovirt-engine-dwhd grafana-server
    2. Backup the ovirt_engine_history database:
      # grep 'DWH_DB_PASSWORD=' /etc/ovirt-engine/engine.conf.d/10-setup-dwh-database.conf
      
      # PGPASSWORD=your-datawarehouse-db-pw /usr/bin/pg_dump \
       -E UTF8 \
       --disable-dollar-quoting \
       --disable-triggers \
       -U ovirt_engine_history \
       -h localhost \
       -p 5432 \
       --format=custom \
       --file=/var/lib/ovirt-engine-dwh/backups/dwh-$(date +%Y%m%d%H%M%S).$$.dump ovirt_engine_history
    3. Vacuum the ovirt_engine_history database:
      # /usr/share/ovirt-engine-dwh/bin/dwh-vacuum.sh -f -v
    4. Start the ovirt-engine, ovirt-engine-dwhd, and grafana-server services:
      # systemctl start ovirt-engine ovirt-engine-dwhd grafana-server
  4. Check the post-vacuum database size:
    # /usr/share/ovirt-engine/dbscripts/engine-psql.sh -c "SELECT datname as db_name, pg_size_pretty(pg_database_size(datname)) as db_usage FROM pg_database"