mongodb 将Mongo从4.4升级到5.0,现在DB无法启动

of1yzvn4  于 2022-12-26  发布在  Go
关注(0)|答案(2)|浏览(431)

我的数据库在AWS中运行,我升级到Mongo 5.0。现在我甚至无法启动数据库,因为我得到以下错误:

mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2021-10-25 00:16:42 UTC; 26min ago
     Docs: https://docs.mongodb.org/manual
  Process: 3888 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=62)
  Process: 3886 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 3883 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 3881 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

根据文档,status=62表示存在不兼容问题。
我想降级回4.4,但没有明确的方法。Mongo Docs假设DB正在运行,并要求运行db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )
我无法运行这个命令,因为DB甚至不会启动。
我删除了5.0的二进制文件,但没有做任何事情。DB版本仍然显示“5.0.3”
你能提供的任何帮助都将不胜感激
下面是一些附加输出:

Unit mongod.service has begun starting up.
mongod[3591]: about to fork child process, waiting until server is ready for connections.
mongod[3591]: forked process: 3594
mongod[3591]: ERROR: child process failed, exited with 62
mongod[3591]: To see additional information in this output, start without the "--fork" option.
sudo[3579]: pam_unix(sudo:session): session closed for user root
systemd[1]: mongod.service: control process exited, code=exited status=62
systemd[1]: Failed to start MongoDB Database Server.
Subject: Unit mongod.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mongod.service has failed.
--
-- The result is failed.
systemd[1]: Unit mongod.service entered failed state.
systemd[1]: mongod.service failed.

运行了以下命令:cat mongod.log | tail -10

{"t":{"$date":"2021-10-25T22:49:33.833+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1635202173:833865][3594:0x7f52128ce280], WT_SESSION.checkpoint: [WT_VERB_CHECKPOINT_PROGRESS] saving checkpoint snapshot min: 2, snapshot max: 2 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 441594"}}
{"t":{"$date":"2021-10-25T22:49:33.839+00:00"},"s":"I",  "c":"STORAGE",  "id":4795903, "ctx":"initandlisten","msg":"Reconfigure complete","attr":{"durationMillis":127}}
{"t":{"$date":"2021-10-25T22:49:33.839+00:00"},"s":"I",  "c":"STORAGE",  "id":4795902, "ctx":"initandlisten","msg":"Closing WiredTiger","attr":{"closeConfig":"leak_memory=true,"}}
{"t":{"$date":"2021-10-25T22:49:33.839+00:00"},"s":"I",  "c":"STORAGE",  "id":22430,   "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":"[1635202173:839582][3594:0x7f52128ce280], close_ckpt: [WT_VERB_CHECKPOINT_PROGRESS] saving checkpoint snapshot min: 4, snapshot max: 4 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 441594"}}
{"t":{"$date":"2021-10-25T22:49:33.867+00:00"},"s":"I",  "c":"STORAGE",  "id":4795901, "ctx":"initandlisten","msg":"WiredTiger closed","attr":{"durationMillis":28}}
{"t":{"$date":"2021-10-25T22:49:33.867+00:00"},"s":"I",  "c":"STORAGE",  "id":22279,   "ctx":"initandlisten","msg":"shutdown: removing fs lock..."}
{"t":{"$date":"2021-10-25T22:49:33.867+00:00"},"s":"I",  "c":"-",        "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2021-10-25T22:49:33.867+00:00"},"s":"I",  "c":"FTDC",     "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
{"t":{"$date":"2021-10-25T22:49:33.867+00:00"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2021-10-25T22:49:33.867+00:00"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":62}}
vh0rcniy

vh0rcniy1#

这解决了我同样的问题。

删除版本5.0

停止mongod服务
sudo systemctl stop mongod
sudo rm /tmp/mongodb-27017.sock
备份您的数据目录
cp -r /var/lib/mongodb /var/lib/mongodb_backup
删除版本5.0及其数据
sudo apt purge mongodb-org
sudo apt autoremove
sudo rm /etc/mongod.conf

# Remove all mongo-org apt sources
sudo rm /etc/apt/sources.list.d/mongodb-org-*

安装版本4.4

按照mongodb v4.4 documentation中的说明操作

运行4.4版服务器
sudo systemctl start mongod
sudo systemctl status mongod
使用mongodump备份数据
mkdir $HOME/Desktop/mongo-data
cd $HOME/Desktop/mongo-data

mongodump

删除版本4.4

停止mongod服务
sudo systemctl stop mongod
sudo rm /tmp/mongodb-27017.sock
删除数据目录
rm -r /var/lib/mongodb
删除版本4.4及其数据
sudo apt purge mongodb-org
sudo apt autoremove
sudo rm /etc/mongod.conf

# Remove all mongo-org apt sources
sudo rm /etc/apt/sources.list.d/mongodb-org-*

安装版本5.0

按照此处的说明mongodb v5.0 documentation

运行5.0版服务器
sudo systemctl start mongod
sudo systemctl status mongod
使用mongorestore恢复数据
cd $HOME/Desktop/mongo-data

mongorestore

**恭喜!**现在您的旧数据可以在v5.0上使用了

vyswwuz2

vyswwuz22#

我遇到了同样的问题,即使是全新安装,我也无法在没有得到退出代码62EXIT_NEED_DOWNGRADE的情况下从4.4升级到5.0
无论如何,我的解决方案是使用mongodump备份数据库(version 4.2),从系统中完全删除MongoDB,然后再次干净地安装它,但安装的是最新版本(6.0),然后我就可以使用mongorestore恢复数据库,没有任何问题。
备份允许我跳过从4.24.4、到5.06.0的升级,没有任何错误。

相关问题