【发布时间】:2021-11-11 08:33:39
【问题描述】:
只是为了透明,我不知道怎么做,但我确定我自己挖了一个洞。假设我是驴脑。这是 Ubuntu 的全新安装 - 我在这方面的宝贵数据为零,因此如果我需要删除任何内容,我关心的不会丢失任何东西。
我尝试在 Ubuntu 20.04 上安装 MongoDB。后来我意识到有一种不同的方法可以做到这一点,但我按照学校的指示使用自制软件安装它。这对我来说效果不太好,所以我找到了一个与学校不同的指南,涵盖了 Ubuntu 安装。我通过执行以下操作来遵循这一点
sudo apt update
sudo apt-get install mongodb
mongod --version \\which works still, returns im on version 3.6.8
然后,指南将介绍启动和停止服务并检查它
sudo service mongodb status 但返回 Unit mongodb.service could not be found
我认为我的安装搞砸了,我把它搞砸了,所以我只需要找到一个卸载和重新安装的指南。所以我开始寻找卸载指南,我找到了这个Failed to start mongod.service: Unit mongod.service not found,所以我以 58 票尝试了那个卸载指南。
sudo service mongod stop
sudo apt-get purge mongodb-org*
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
这基本上告诉我那些东西不存在。所以我认为我会很好地继续安装,因为我什至找不到我想要删除的东西。所以我继续进行安装,前几步运行良好,但我被困在这里 -
➜ lib sudo apt-get install -y mongodb-org
Reading package lists... Done
Building dependency tree
Reading state information... Done
mongodb-org is already the newest version (5.0.3).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
mongodb-org-database : Depends: mongodb-org-server but it is not going to be installed
Depends: mongodb-org-mongos but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
➜ lib sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
libboost-program-options1.71.0 libgoogle-perftools4 libpcrecpp0v5
libsnappy1v5 libtcmalloc-minimal4 libyaml-cpp0.6 mongodb-server-core
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
mongodb-org-mongos mongodb-org-server
The following NEW packages will be installed:
mongodb-org-mongos mongodb-org-server
0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded.
12 not fully installed or removed.
Need to get 0 B/44.6 MB of archives.
After this operation, 183 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 224051 files and directories currently installed.)
Preparing to unpack .../mongodb-org-server_5.0.3_amd64.deb ...
Unpacking mongodb-org-server (5.0.3) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-server_5.0.3_
amd64.deb (--unpack):
trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-
core 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../mongodb-org-mongos_5.0.3_amd64.deb ...
Unpacking mongodb-org-mongos (5.0.3) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-mongos_5.0.3_
amd64.deb (--unpack):
trying to overwrite '/usr/bin/mongos', which is also in package mongodb-server-
core 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/mongodb-org-server_5.0.3_amd64.deb
/var/cache/apt/archives/mongodb-org-mongos_5.0.3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
➜ lib sudo service mongodb status
[sudo] password for brainzilla:
Unit mongodb.service could not be found.
所以我有点卡住了,我真的不知道在哪里看这一点。前几天晚上我让它工作了,但我相信它归结为配置文件的一些所有权问题?而且我不记得那个指南在我横冲直撞时去了哪里。但我能够从学校获得我的项目,运行nodemon start,它显示我已连接到 localhost:27017 和所有内容。我重新启动了我的电脑,只是想看看第二天我是否会遇到任何奇怪的事情,果然它不会再工作了。 我试图找到我之前参考过的指南,但我丢失了它......
【问题讨论】:
-
你检查Install MongoDB Community Edition on Ubuntu了吗?请仔细遵循本指南。注意声明 Ubuntu 提供的 mongodb 包不是 MongoDB Inc. 维护的,与官方的 mongodb-org 包有冲突。如果您已经在 Ubuntu 系统上安装了 mongodb 包,则必须先卸载 mongodb 包,然后再继续执行这些说明。
-
@WernfriedDomscheit 是的,我尝试的卸载命令直接来自该指南。