每当我重新启动docker/elk映像时,数据就会丢失 [英] The data is getting lost whenever I restart the docker/elk image

查看:992
本文介绍了每当我重新启动docker/elk映像时,数据就会丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用docker/elk映像在kibana仪表板(版本6.6.0)中显示我的数据,并且效果很好.我像使用下面的命令一样启动了该服务.

I'm using docker/elk image to display my data in kibana dashboard (Version 6.6.0) and It works pretty good. I started the service like using below command.

Docker Image git repo :

 https://github.com/caas/docker-elk

命令:

    sudo docker-compose up --detach

期望它将在后台运行,并且按预期进行.两天后,服务器启动并运行,第三天,仅kibana停止运行.并在下面的命令中使用以使其启动并运行.

Expecting that it will run background, and did as expected. After two days the server up and running the and third day the kibana alone getting stopped. and Used below command to make it up and running.

    sudo docker run -d <Docer_image_name>

当我使用docker ps命令时,它已经启动并正在运行.但是,当我尝试在chrome浏览器中访问kibana服务器时,它说无法访问.

It's up and running when I use docker ps command. But when I tried to hit the kibana server in chrome browser it says not reachable.

所以我只是习惯下面的命令来重新启动服务.

So I just used to below command to restart the service.

    sudo docker-compose down

此后,我可以在chrome浏览器中看到已启动并正在运行的kibana服务器,但确实看到所有数据都丢失了.

After that I can see kibana server in chrome browser which is up and running but I do see all my data is lost.

我在詹金斯的URL下面使用了该数据.

I used below URL in jenkins to collect the data.

`http://hostname:9200/ecdpipe_builds/extern`al 

知道如何解决此问题吗?

Any idea how can I resolve this issue?

推荐答案

我没有在您的GitHub docker-compose文件中看到您提到的映像的持久性存储配置.

I did not see the persistent storage configuration the image you mentioned in their GitHub docker-compose file.

如果您未提供持久性存储配置,这对于丢失Docker容器的数据很常见.因此,如果没有持久性配置docker-compose文件,docker-compose down可能会导致您丢失数据.

This is common to lost data in case of docker container if you did not provide persistent storage configuration. so docker-compose down may cause to lost you data if there is no persistent configuration docker-compose file.

持久记录数据

为了保持跨容器重启的日志数据,该映像会挂载 /var/lib/elasticsearch —这是Elasticsearch的目录 将其数据存储在—作为卷中.

In order to keep log data across container restarts, this image mounts /var/lib/elasticsearch — which is the directory that Elasticsearch stores its data in — as a volume.

但是,您可能想使用专用数据量来保持此状态 记录数据,例如,以方便备份和还原操作.

You may however want to use a dedicated data volume to persist this log data, for instance to facilitate back-up and restore operations.

一种执行此操作的方法是使用docker的-v挂载一个名为Docker的卷 选项,如:

One way to do this is to mount a Docker named volume using docker's -v option, as in:

$ sudo docker run -p 5601:5601 -p 9200:9200  -p 5044:5044 \
    -v elk-data:/var/lib/elasticsearch --name elk sebp/elk

此命令将命名卷elk-data挂载到 /var/lib/elasticsearch(并自动创建该卷,如果它 不存在您也可以使用docker手动预先创建它 批量创建麋鹿数据).

This command mounts the named volume elk-data to /var/lib/elasticsearch (and automatically creates the volume if it doesn't exist; you could also pre-create it manually using docker volume create elk-data).

因此,您可以在docker-compose文件中相应地设置这些路径.这是您可以查看 elk-docker-persisting-log-data elk-docker-persisting-log-data

So you can set these paths in your docker-compose file accordingly. Here is the link that you can check elk-docker-persisting-log-data

这篇关于每当我重新启动docker/elk映像时,数据就会丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆