Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change location of Influxdb storage folder?

Tags:

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 ?

like image 909
Alexey Batsman Avatar asked Feb 05 '15 17:02

Alexey Batsman


People also ask

Where is InfluxDB stored Windows?

In the default configurations for Windows, the data is stored in the directory c:\Users\<username>\. influxdb\data\ .

How is InfluxDB data stored?

InfluxDB stores data in shard groups. Shard groups are organized by retention policy (RP) and store data with timestamps that fall within a specific time interval called the shard duration. The shard group duration is also configurable per RP.


2 Answers

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.

like image 87
Gustavo Bezerra Avatar answered Oct 21 '22 14:10

Gustavo Bezerra


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
like image 44
debuglevel Avatar answered Oct 21 '22 15:10

debuglevel