Alexey Batsman
Alexey Batsman

Reputation: 371

How to change location of Influxdb storage folder?

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 ?

Upvotes: 27

Views: 71906

Answers (2)

debuglevel
debuglevel

Reputation: 508

For InfluxDB 2.0:

In InfluxDB 2.0 the data directories are below ~/.influxdbv2 by default.

Actually, there are 2 data storages for bolt (various key-value configurations) and engine (the TSM database).

From the documentation, to change the location to the bolt database:

  • Default: ~/.influxdbv2/influxd.bolt
  • influxd flag: influxd --bolt-path=~/.influxdbv2/influxd.bolt
  • Environment variable: export INFLUXD_BOLT_PATH=~/.influxdbv2/influxd.bolt
  • Configuration file: bolt-path: /users/user/.influxdbv2/influxd.bolt

From the documentation, to change the location to the engine database:

  • Default: ~/.influxdbv2/engine
  • influxd flag: influxd --engine-path=~/.influxdbv2/engine
  • Environment variable: export INFLUXD_ENGINE_PATH=~/.influxdbv2/engine
  • Configuration file: engine-path: /users/user/.influxdbv2/engine

Upvotes: 10

Gustavo Bezerra
Gustavo Bezerra

Reputation: 11054

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.

Upvotes: 29

Related Questions