How I can remove old data from my heat database from my Director node

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux OpenStack Platform 7
  • Red Hat OpenStack Platform 8
  • Red Hat OpenStack Platform 10

Issue

  • We notice that our Openstack Director node mysql database was about to fill the whole partition. After flushing keystone tokens we notice the heat.raw_template table is taking most of the space.

Resolution

Purge heat stack DB entries which are marked as deleted.

The following command can be used to manually flush the deleted entries from the heat database.

# heat-manage purge_deleted

By default this purges stack entries which were deleted more than 90 days ago.

To purge newer entries you can provide a specific age using the -g parameter.

# heat-manage purge_deleted -g days 2

Root Cause

The Heat database is not getting cleaned, and so keeps growing on and fill the filesystem up.

Diagnostic Steps

$ mysql
MariaDB [(none)]> use heat;

MariaDB [heat]> SELECT CONCAT(table_schema, '.', table_name) as "Table", 
CONCAT(ROUND(table_rows / 1000000, 2), 'M') as "rows", 
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') as "DATA", 
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') as "idx", 
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') as "total_size", ROUND(index_length / data_length, 2) as "idxfrac" 
FROM information_schema.TABLES 
ORDER  BY data_length + index_length DESC 
LIMIT  10;


+--------------------------+-------+-------+-------+------------+---------+
| Table                    | rows  | DATA  | idx   | total_size | idxfrac |
+--------------------------+-------+-------+-------+------------+---------+
| heat.raw_template        | 0.01M | 3.25G | 0.00G | 3.25G      |    0.00 |
| keystone.token           | 0.12M | 0.94G | 0.04G | 0.98G      |    0.04 |
| heat.event               | 0.04M | 0.08G | 0.01G | 0.09G      |    0.14 |
| ceilometer.sample        | 0.11M | 0.02G | 0.01G | 0.03G      |    0.57 |
| heat.stack               | 0.01M | 0.00G | 0.00G | 0.01G      |    1.66 |
| ceilometer.metadata_text | 0.04M | 0.00G | 0.00G | 0.00G      |    1.00 |
| ceilometer.resource      | 0.00M | 0.00G | 0.00G | 0.00G      |    0.05 |
| heat.resource            | 0.00M | 0.00G | 0.00G | 0.00G      |    0.03 |
| heat.software_config     | 0.00M | 0.00G | 0.00G | 0.00G      |    0.01 |
| nova.instances           | 0.00M | 0.00G | 0.00G | 0.00G      |    0.06 |
+--------------------------+-------+-------+-------+------------+---------+

MariaDB [heat]> SELECT      table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES  WHERE table_schema = "heat"     AND
table_name = "raw_template";

+--------------+------------+
| Table        | Size in MB |
+--------------+------------+
| raw_template |   11655.55 |
+--------------+------------+

MariaDB [heat]> select count(*) from raw_template;
+----------+
| count(*) |
+----------+
|     9540 |
+----------+
SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.