【问题标题】:Mongo DB collections are not found未找到MongoDB集合
【发布时间】:2017-08-28 04:24:15
【问题描述】:

我使用 MongoDB 作为我的数据存储,版本 v3.4.1。我正在使用 mongo 的 docker 映像,像这样运行它:

docker run -d -p 27017:27017 -v /home/rancher/data:/data/db --name mongodb mongo:latest

之后我创建了许多数据库和集合。一个多月没问题;但现在我无法在数据库中找到任何集合。此列出集合的命令显示一个空列表:show dbs。或者,如果我执行use mydb,则show collections 不会显示任何内容。

这些是 /home/rancher/data 文件夹中的数据:

collection-0-‌​-4220404477553112134‌​.wt
集合-0-1041804628168690390.w‌​t
收藏2--4220404477553112134.wt
收藏-2-1041804628168690390.wt
诊断数据
index-1--4220404477553112134.wt
index-1-1041804628168690390.wt
index-3--4220404477553112134.wt
index-3-1041804628168690390.wt
index-4-1041804628168690390.wt
杂志
_mdb_catalog.wt
mongod.lock
sizeStorer.wt
storage.bson
有线老虎
WiredTiger.lock
WiredTiger.turtle
WiredTiger.wt
WiredTigerLAS.wt

谁能告诉我为什么这些集合在 mongo DB 中不能持久化?

【问题讨论】:

  • 当您查看主机上的位置'home/rancher/data'时,它是否包含任何数据文件?
  • 您能否准确描述一下您找不到任何收藏品的原因?它们没有出现在 mongo shell 中 show collections 给出的列表中 - 还是别的什么?
  • @VinceBowdren,这些是 /home/rancher/data 文件夹中的数据 WiredTiger, _mdb_catalog.wt, diagnostic.data, index-4-1041804628168690390.wt,WiredTiger.lock,collection-0- -4220404477553112134.wt indect-1--4220404477553112134 .wtning-1-4220404477553112134.wtired.turtle,collection-0-0- 0-1-1-10418046030.wt,mongod.lock,wiredtiger.wt collection-2--4220404477553112134.wt,depend -3--4220404477553112134.wt, sizeStorer.wt,WiredTigerLAS.wt collection-2-1041804628168690390.wt, index-3-1041804628168690390.wt, storage.bson
  • 一旦我创建了集合,它会在几天后消失。所以我无法继续我的任务。当我执行此命令列出集合时,它显示空列表 show dbs 然后使用 mydb show collections 什么都不会显示在这里你能帮助克服这个问题吗?

标签: mongodb docker


【解决方案1】:

您可能遇到了mongo:latest 标签以及 mongodb 如何更改它们用于数据文件的默认驱动程序的问题。

在任何图像上使用:latest 标记是个坏主意,因为图像之间会发生变化,这样的问题可能会发生。

切换到以前的版本,比如 3.2,看看它是否能找到你的数据

docker run -d -p 27017:27017 -v /home/rancher/data:/data/db --name mongodb mongo:3.2.12

【讨论】:

  • 与版本我也面临同样的问题。现在我使用的是 3.2.0 版本
【解决方案2】:

我也遇到了同样的问题。这是我找到的解决方案。请检查您的 mongodb 端口是否对互联网开放。如果是这样,请将其限制在服务器上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多