How to change location of Influxdb storage folder?

Alexey Batsman picture Alexey Batsman · Feb 5, 2015 · Viewed 31k times · Source

I've Installed package from the official site by instruction. By default the physical destination of database folder is '/opt/influxdb/shared'.

I've tried to change properties of config file and written it properly. But after that I can't start the influxdb service.

[storage]

dir = "/media/alex/Second/InfluxStorage/data/db" //my settings

How I can change the default database directory ?

Answer

Gustavo Bezerra picture Gustavo Bezerra · Mar 21, 2017

EDIT: This is for InfluxDB v1.x only. It has been reported to not work for InfluxDB v2.x.

Make a new directory where you want to put your data and set the appropriate permissions, e.g.:

mkdir /new/path/to/influxdb
sudo chown influxdb:influxdb influxdb

Edit the following three lines of your /etc/influxdb/influxdb.conf (/usr/local/etc/influxdb.conf on macOS) so that they point to your new location:

# under [meta]
dir = "/new/path/to/influxdb/meta"

# under [data]
dir = "/new/path/to/influxdb/data"
wal-dir = "/new/path/to/influxdb/wal"

Restart the InfluxDB daemon.

sudo service influxdb restart  # Ubuntu/Debian
brew services restart influxdb  # macOS/homebrew

Done!

In case you want to move existing data, just simply copy the existing data (location can be found at influxdb.conf; /var/lib/influxdb on Ubuntu/Debian) to your new desired location before editing influxdb.conf and make sure the new folder has the appropriate permissions/ownership.

There is some information about backups/restores on the official docs, however just plain copying worked for me.

The above was tested on InfluxDB v1.2 on macOS/Ubuntu/Raspbian.