Upgrade InfluxDB version 1.x to 2.3

I needed to upgrade InfluxDB to version 2.3 because I wanted the possibility to visualize and explore my data which is supported out of the box in version 2 of InfluxDB via a web interface. I wanted to summarize the upgrade here in case any other need it.

First, install InfluxDB version 2 alongside version 1.

Then before you run version 2, call it with the upgrade argument together with the path to version 1.

influxd upgrade --v1-dir "path to the data-directory of influxd v1"

I’m running OH under windows, so my path was “C:\Users\USER\.influxdb”, it’s the folder containing the data folder, meta folder and wal folder.

When running the upgrade command you will be asked to fill in a username, a password, a organization and a bucket.

Also, I had the default paths for InfluxDB. For me that meant that the different versions got different folders on the computer:

V1: C:\Users\USER\.influxdb
V2: C:\Users\USER\.influxdbv2

So I tried to run the upgrade command several times, and just deleted the influxdbv2-folder if something got wrong and repeated the process. Until I got it right. Also I took a copy of the V1-folder just to be sure, but I do not think that was necessary, since they live in different folders and the upgrade didn’t seem to change anything in the V1-folder.

InfluxDB V1 - V2:

V1 Database         = V2 Organization
V1 Retention Policy = V2 Bucket

After the upgrade has finished successfully, you will need to shutdown V1 before starting V2. After starting V2, log into the web interface and create a user token for OH.

  • Go to http://localhost:8086/ and login with your username and password
  • In the left menu, select “Load Data” and navigate to “API Tokens”.
  • Create an “all access api token” for OH.

I got rid of the config-file for InfluxDB at this moment and continued to set it up in the user interface in OH.

In OH3, navigate to settings-other services-influxdb persistence service. Fill inn the new information:

  • Should be the same database url if you don’t have customized this
  • Choose InfluxDB 2
  • Username not needed
  • Password not needed
  • Fill in the authentication token you created
  • Fill in the organization name
  • Fill in the bucket name. Here I had to look into the InfluxDB data explorer of the web ui and see what it was named. For me it consisted of both organization name and bucket name, separated with a forward slash. Like this “openhab_db/autogen”. I’m sure I specified the bucket name to only autogen, but I couldnt read my persisted data from InfluxDB before I specified it like this.

It is also necessary to let InfluxDB start automatically with your system.

For me this was all. After a restart of OH it correctly read and write from V2 of InfluxDB.

5 Likes

Thank you @jmelhus,
great tutorial. Up to now, I didn’t dare to upgrade, but with your tutorial, I will give it a try.
Joerg