mongodb - MongoDB 从 3.6 升级到 4.0:如何修复“collection does not have uuid in kvcatalog”异常?
问题描述
我在Rancher编排的容器化环境中运行 MongoDB 副本集。推出最新更新后,MongoDB已从3.6.x升级到4.0.x(最新)。
没有遵循升级路径,因此,当尝试绑定包含数据库存储的卷时,服务无法启动,并退出并出现以下异常:
STORAGE [initandlisten] exception in initAndListen: MustDowngrade: Collection does not have UUID in KVCatalog. Collection: admin.system.version, terminating
即使尝试mongod
使用该--repair
选项启动,我也会得到相同的结果。我也尝试将容器回滚到MongoDB 3.6.16,但日志版本现在不兼容。
我们没有卷的快照,因此无法恢复数据(这不是生产环境)。我在网上找到的唯一解决方案mongodump
不适用,因为它建议利用and mongorestore
,需要一个正在运行的数据库并附加数据存储。
我的想法不多了,关于如何解决这个问题的任何建议?
解决方案
我在 Mac OS 上使用 Homebrew 将 MongoDB 从 3.6 更新到 4.2,并遇到了类似的情况。
由于 formulamongodb
已从 homebrew-core 中删除,因此 mongodb 团队维护了一个自定义 Homebrew tap。
以下步骤是我使用 Homebrew 将 MongoDB 从 3.6 升级到 4.2 的解决方案:
- 从 Homebrew 卸载旧版本的 mongodb
# If you run mongodb in background service, stop it first.
brew services stop mongodb
# If you have multiple version of mongodb, you might need to add `--force` option for deleting all of them at once.
brew uninstall mongodb
- 从自定义 Homebrew 水龙头安装新的 mongodb
brew tap mongodb/brew
brew install mongodb-community@3.6
- 将 mongodb-community@3.6 添加到您的 PATH
echo 'export PATH="/usr/local/opt/mongodb-community@3.6/bin:$PATH"' >> ~/.bash_profile
重新启动终端,然后运行
mongod
打开另一个选项卡或终端窗口以运行
mongodump
终止
mongod
卸载 mongodb-community@3.6 并重新安装 mongodb-community
brew uninstall mongodb-community@3.6
brew install mongodb-community
- 用旧的 mongo 数据结构删除旧数据
rm -rf /data/db/*
跑
mongod
打开另一个选项卡或终端窗口以运行
mongorestore dump/
一旦mongorestore
完成,mongod
将被终止。您可以将 mongodb 作为后台服务运行,也可以mongod
再次运行。mongo
使用或 Robo 3T(以前的 Robomongo)打开 MongoDB ,你会看到你的数据和往常一样好。
希望能帮助到你。
推荐阅读
- python - 将 na 值分配给 Pandas 数据框不起作用
- javascript - .替换功能不起作用 - 使用谷歌表格脚本编辑器的自动邮件模板
- r - 为什么是NA | 错误 = 不适用?
- react-native - 带有 React Native 视频的自定义播放/暂停按钮 - 获取 JSON 值错误消息
- python - 在 python 图中将 2^n 转换为数值
- tensorflow - 计算 YAMNET 中某一层的梯度
- c# - Razor 页面中的相同 URL 端点
- html - 输入元素(由 vuetify 生成)不会为长文本换行
- php - 如何在 php 中使用 http 身份验证 cURL SSL URL?
- autodesk-forge - 使用 Revit API 和设计自动化从模板文件创建项目文件