Upgrading from InfluxDB 1.8 to 2.7 using Docker Compose

Simplified approach to upgrading from InfluxDB 1.8 to 2.7 using Docker Compose:

Step 1: Create Docker Compose for InfluxDB 1.8

  1. Create a docker-compose.yml file for InfluxDB 1.8:
version: '3'
services:
  influxdb:
    image: influxdb:1.8
    ports:
      - "8086:8086"
    volumes:
      - ./influxdb:/var/lib/influxdb
  1. Start InfluxDB 1.8:
docker-compose up -d
  1. Restore your InfluxDB 1.8 data (if needed):
    • Copy your InfluxDB 1.8 backup data into the ./influxdb directory (where data is mounted).
    • Make sure the data is located in the correct directories like ./influxdb/meta, ./influxdb/data, etc.
  2. Verify the data restoration:
    • Use the InfluxDB 1.8 CLI or HTTP API to check if your data is restored properly.
docker exec -ti container_name influx -host localhost -port 8086

Step 2: Create Docker Compose for InfluxDB 2.7 Upgrade

  1. Modify your docker-compose.yml file to set up InfluxDB 2.7:
version: '3'
services:
  influxdb:
    image: influxdb:2.7
    ports:
      - "8086:8086"
    volumes:
      - ./influxdb:/var/lib/influxdb
      - ./influxdb2:/var/lib/influxdb2
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=upgrade
      - DOCKER_INFLUXDB_INIT_USERNAME=my-user
      - DOCKER_INFLUXDB_INIT_PASSWORD=my-password
      - DOCKER_INFLUXDB_INIT_ORG=my-org
      - DOCKER_INFLUXDB_INIT_BUCKET=my-bucket
      - DOCKER_INFLUXDB_INIT_RETENTION=30d
  1. Stop the InfluxDB 1.8 container:
docker-compose down
  1. Start the upgraded InfluxDB 2.7 container:
docker-compose up -d

This will upgrade the data automatically from InfluxDB 1.8 to 2.7. It will create the required structure for InfluxDB 2.x in the ./influxdb2 directory and migrate the data from ./influxdb.

Step 3: Verify the Upgrade

  1. Check the logs to confirm the upgrade:
docker logs -f container_name
  1. Access InfluxDB 2.x web UI: Go to http://localhost:8086 and log in using the credentials set in the environment variables (my-user and my-password).
  2. Verify your data: Check if the data from InfluxDB 1.x has been properly migrated.

Step 4: Migrate Continuous Queries

  1. Check ~/continuous_queries.txt inside the container for the exported continuous queries:
docker exec -it container_name cat /root/continuous_queries.txt
  1. Convert Continuous Queries to Tasks:

This is a high-level, streamlined process for upgrading InfluxDB from version 1.8 to 2.7 using Docker. Each step ensures that the data migration is smooth, with the ability to restore and verify the data at each phase.

Leave a Comment