Simplified approach to upgrading from InfluxDB 1.8 to 2.7 using Docker Compose:
Step 1: Create Docker Compose for InfluxDB 1.8
- 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
- Start InfluxDB 1.8:
docker-compose up -d
- 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.
- Copy your InfluxDB 1.8 backup data into the
- 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
- 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
- Stop the InfluxDB 1.8 container:
docker-compose down
- 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
- Check the logs to confirm the upgrade:
docker logs -f container_name
- Access InfluxDB 2.x web UI: Go to
http://localhost:8086
and log in using the credentials set in the environment variables (my-user
andmy-password
). - Verify your data: Check if the data from InfluxDB 1.x has been properly migrated.
Step 4: Migrate Continuous Queries
- Check
~/continuous_queries.txt
inside the container for the exported continuous queries:
docker exec -it container_name cat /root/continuous_queries.txt
- Convert Continuous Queries to Tasks:
- Refer to Migrate continuous queries to tasks to manually create equivalent tasks in InfluxDB 2.x.
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.