influxdb: How To Compact your Database files
If your series are created or deleted very often it might be necessary to compact the series files in order to reduce their size on disk…
If your series are created or deleted very often it might be necessary to compact the series files in order to reduce their size on disk, those files are inside the /data and /wal directories of influxdb directory.
Steps to perform the task
Stop influxdb
This operation needs to take place with influxdb stopped.$ sudo systemctl stop influxdb
Use the influx_inspect tool to compact the series files
To run this command you need to run this command as the user that influxdb runs, else there will be ownership issues and the database will be unusable
- su-influxdb: To run the command as the influxdb user, in your case the user might not be the same, the easiest way to identify this is to ls -l in the directory where data files exist
- -datadir /files/influxdb/data ← The data dir, in your case you can find the location by examining the influxdb.conf file
- -waldir /files/influxdb/wal ← The wal dir, in your case you can find the location by examining the influxdb.conf filesu - influxdb -s /bin/bash -c "influx_inspect buildtsi -compact-series-file -datadir /files/influxdb/data -waldir /files/influxdb/wal"
If you have a lot of data it might take a lot of time to complete the operation, after the completion you can start influxdb.
Start influxdb$ sudo systemctl stop influxdb
if the database starts without any issue probably everything gone well!