升级到 Ubuntu/Kubuntu 18.04 后似乎破坏了我的 MongoDB 服务器。
我试图重新安装 Mongo,但我仍然无法像以前一样启动它:
$ sudo apt-get install mongodb-server
$ mongo --version
MongoDB shell version v3.6.3
git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
OpenSSL version: OpenSSL 1.1.0h 27 Mar 2018
allocator: tcmalloc
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
状态:
$ sudo service mongodb status
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-10-07 14:30:40 BST; 17s ago
Docs: man:mongod(1)
Process: 5925 ExecStart=/usr/bin/mongod --unixSocketPrefix=${SOCKETPATH} --config ${CONF} $DAEMON_OPTS (code=exited, status=62)
Main PID: 5925 (code=exited, status=62)
Oct 07 14:30:38 lau-desktop systemd[1]: Started An object/document-oriented database.
Oct 07 14:30:40 lau-desktop systemd[1]: mongodb.service: Main process exited, code=exited, status=62/n/a
Oct 07 14:30:40 lau-desktop systemd[1]: mongodb.service: Failed with result 'exit-code'.
有任何想法吗?
编辑:
当我尝试安装 mongo 4 时,出现错误:
Preparing to unpack .../mongodb-org-server_4.0.3_amd64.deb ...
Unpacking mongodb-org-server (4.0.3) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-server_4.0.3_amd64.deb (--unpack):
trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../mongodb-org-mongos_4.0.3_amd64.deb ...
Unpacking mongodb-org-mongos (4.0.3) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-mongos_4.0.3_amd64.deb (--unpack):
trying to overwrite '/usr/bin/mongos', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../mongodb-org-tools_4.0.3_amd64.deb ...
Unpacking mongodb-org-tools (4.0.3) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-tools_4.0.3_amd64.deb (--unpack):
trying to overwrite '/usr/bin/bsondump', which is also in package mongo-tools 3.6.3-0ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/mongodb-org-server_4.0.3_amd64.deb
/var/cache/apt/archives/mongodb-org-mongos_4.0.3_amd64.deb
/var/cache/apt/archives/mongodb-org-tools_4.0.3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
编辑2:
$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
mongodb-org : Depends: mongodb-org-server but it is not installed
Depends: mongodb-org-mongos but it is not installed
Depends: mongodb-org-tools but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
编辑 3:
$ mongo --versionMongoDB shell version v4.0.3
git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
OpenSSL version: OpenSSL 1.1.0h 27 Mar 2018
allocator: tcmalloc
modules: none
build environment:
distmod: ubuntu1804
distarch: x86_64
target_arch: x86_64
$ sudo service mongodb status
● mongodb.service
Loaded: masked (/dev/null; bad)
Active: failed (Result: exit-code) since Sun 2018-10-07 15:12:14 BST; 1h 7min ago
Main PID: 2232 (code=exited, status=62)
Oct 07 15:12:13 lau-desktop systemd[1]: Started An object/document-oriented database.
Oct 07 15:12:14 lau-desktop systemd[1]: mongodb.service: Main process exited, code=exited, status=62/n/a
Oct 07 15:12:14 lau-desktop systemd[1]: mongodb.service: Failed with result 'exit-code'.
按照Mongo官方网站的指南,我把它修好了。
步骤1:
第2步:
第 3 步:
第4步:
第 5 步:
第 6 步:
我也面临同样的问题。接受的答案对我不起作用,因为我正在尝试安装 version
4.0.5
。我喜欢分享我是如何解决这个问题的。从错误消息中,我了解到 apt 正在尝试用最新版本覆盖
/usr/bin/bsondump
version3.6.3
(在撰写本文时)4.0.5
。早些时候,我确实删除了,之前安装了 mongodb 版本3.6.3
。不知怎的,mongo-tools
包裹被留下了。所以,我只需要删除
[email protected]
. 但是,由于安装[email protected]
没有成功完成,我不得不重置apt
之前,我可以用apt
.此命令取消了损坏的软件包安装。
然后,我只需运行以下命令即可删除
[email protected]
最后,我重新运行以下命令来安装最新的 mongodb
有效!