Clean the database
The Compute service (nova) automatically manages database cleanup by using Kubernetes cron jobs configured in the OpenStackControlPlane CR. It follows a three-step sequence: soft-deleting instances, archiving rows to shadow tables, and purging old data.
Database archiving and purging operations can impact database performance during execution. Schedule manual operations during maintenance windows or low-usage periods.
Configure database management Copy linkLink copied!
The Compute service (nova) uses per-cell Kubernetes cron jobs to archive and purge deleted instance records. By default, these jobs run daily at midnight to archive rows older than 30 days and purge rows older than 90 days. You can configure the schedule and retention ages for each cell.
Procedure Copy linkLink copied!
Results Copy linkLink copied!
- Check the status of the database management cron job for a cell:
$ oc events --for=cronjob/nova-<cellname>-db-purgeReplace
<cellname>with the name of the cell, for examplecell0orcell1.
Manual database management commands Copy linkLink copied!
You can manually manage the Compute database by using nova-manage commands inside a nova-conductor pod. Run commands within a cell-specific pod to target an individual cell, or use the --all-cells option from the cell0 conductor pod to target the entire deployment.
- Examples
-
- Archive deleted rows
$ oc exec nova-cell0-conductor-0 -- nova-manage db archive_deleted_rows \ --max_rows <number> \ --before <date> \ --verbose- Purge archived rows from shadow tables
$ oc exec nova-cell0-conductor-0 -- nova-manage db purge \ --before <date> \ --verbose \ --all-cells- Archive and purge in one operation
$ oc exec nova-cell0-conductor-0 -- nova-manage db archive_deleted_rows \ --max_rows <number> \ --purge \ --verbose