influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

Influx 0.9 not picking up old data when new container started

Open marcospedreiro opened this issue 11 years ago • 7 comments

If I create a container and load some data into it, when the container is recreated influx does not pick up the data that was previously created at the mounted location, even though the data exists at that mounted location.

Command to create container: docker run -d -v $PWD/influxdb:/data --name influxdb -p 8083:8083 -p 8086:8086 tutum/influxdb:0.9

Edit: As an aside, is there any way to order by time in descending order?

marcospedreiro avatar Jul 02 '15 18:07 marcospedreiro

Tutum image does not provide recovering data after container restarts. It can only recreate databases. I've modified their Dockerfile with /root/.influxdb volume and it works properly.

FROM tutum/curl:trusty

# Install InfluxDB
ENV INFLUXDB_VERSION 0.9.0
RUN curl -s -o /tmp/influxdb_latest_amd64.deb https://s3.amazonaws.com/influxdb/influxdb_${INFLUXDB_VERSION}_amd64.deb && \
  dpkg -i /tmp/influxdb_latest_amd64.deb && \
  rm /tmp/influxdb_latest_amd64.deb && \
  rm -rf /var/lib/apt/lists/*

# Admin server
EXPOSE 8083

# HTTP API
EXPOSE 8086

# Raft port (for clustering, don't expose publicly!)
#EXPOSE 8090

# Protobuf port (for clustering, don't expose publicly!)
#EXPOSE 8099

VOLUME ["/root/.influxdb"]

ADD influxdb.toml /opt/influxdb/

WORKDIR /opt/influxdb/

CMD ./influxd -config influxdb.toml

Also you need a influxdb.toml in build directory

And you can run run this way:

docker build -t influxdb /path/to/dockerfile
docker run -d -v $PWD/influxdb:/root/.influxdb --name influxdb -p 8083:8083 -p 8086:8086 influxdb

hypersleep avatar Jul 03 '15 13:07 hypersleep

@pauldix also i think InfluxDB need to have an official image on docker hub.

hypersleep avatar Jul 03 '15 13:07 hypersleep

+1 need an official image soon.

phagunbaya avatar Jul 05 '15 20:07 phagunbaya

@hypersleep thank you for the reply, I am deploying and influx container on a kubernetes instance on the GCE, and I am trying to mount a GCE persistent disk to achieve data persistence. I made the following change to the dockerfile:

FROM ubuntu:14.04

RUN apt-get install -y curl

# Install InfluxDB
RUN curl -s -o /tmp/influxdb_latest_amd64.deb https://s3.amazonaws.com/influxdb/influxdb_0.9.1_amd64.deb && \
  dpkg -i /tmp/influxdb_latest_amd64.deb && \
  rm /tmp/influxdb_latest_amd64.deb && \
  rm -rf /var/lib/apt/lists/*

# Admin server
EXPOSE 8083

# HTTP API
EXPOSE 8086

WORKDIR /opt/influxdb/

CMD ./influxd -config /etc/opt/influxdb/influxdb.conf

Just for completion, this is my current status:

When I recreated a container (pod) on the gce instance I got the following error in the influx logs. However, if I recreate the replication controller itself, it works and I am able to access data. I also had to manually attach the disk to my cluster.

GOMAXPROCS set to 4 using configuration at: /etc/opt/influxdb/influxdb.conf [handoff] 2015/07/06 19:28:26 Failed to start hinted handoff processor: mkdir all: mkdir /var/opt/influxdb/hh: read-only file system

Below is a sanitized version of the replication controller I used:

{
   "kind":"ReplicationController",
   "apiVersion":"v1beta3",
   "metadata":{
      "name":"test-influx",
      "labels":{
         "name":"influx"
      }
   },
   "spec":{
      "replicas":1,
      "selector":{
         "name":"influx"
      },
      "template":{
         "metadata":{
            "labels":{
               "name":"influx"
            }
         },
         "spec":{
            "containers":[
               {
                  "name":"tutum-influx",
                  "image":"gcr.io/projectID/influx-volume:0.9.1",
                  "volumeMounts":[
                     {
                        "mountPath":"/var/opt/influxdb/",
                        "name":"temp-test"
                     }
                  ],
                  "ports":[
                     {
                        "containerPort":8083,
                        "protocol":"TCP"
                     },
                     {
                        "containerPort":8086,
                        "protocol":"TCP"
                     }
                  ]
               }
            ],
            "volumes":[
               {
                  "name":"temp-test",
                  "gcePersistentDisk": {
                     "pdName":"temp-test",
                     "fsType":"ext4",
                     "readOnly":false
                  }
               }
            ]
         }
      }
   }
}

marcospedreiro avatar Jul 06 '15 19:07 marcospedreiro

Just an observation: The data seems invisible - but it is there, if you restart the docker container with the same shared volume, then create a database with the same name and add one datapoint to it, you will be able to see all the previously added data again.

This seems to be a bug. I can replicate it with tutum/influxdb as well as with an image built from the Dockerfile from @hypersleep in this thread.

I've created a test environment here: https://gist.github.com/mvtango/560bf41db3235ab7345d

mvtango avatar Jul 19 '15 11:07 mvtango

@jsternberg do the new Docker builds allow us to close this issue?

beckettsean avatar Apr 22 '16 18:04 beckettsean

Yep. The new docker images render this issue obsolete.

jsternberg avatar May 16 '16 22:05 jsternberg