Mongdb 卸载(和安装)失败:已卸载或者出现问题?

Mongdb 卸载(和安装)失败:已卸载或者出现问题?

我尝试安装 MongoDB,但安装过程中出现问题,我想重新安装。不幸的是,我在尝试删除/清除时遇到错误,我怀疑这些错误可能与我随后重新安装失败有关。

~$ sudo apt-get purge mongo*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'mongodb18-10gen' for glob 'mongo*'
Note, selecting 'mongodb-org-unstable-tools' for glob 'mongo*'
Note, selecting 'mongo20-10gen' for glob 'mongo*'
Note, selecting 'mongodb' for glob 'mongo*'
Note, selecting 'mongodb-org-mongos' for glob 'mongo*'
Note, selecting 'mongo18-10gen' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable-server' for glob 'mongo*'
Note, selecting 'mongodb-enterprise-mongos' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable-enterprise-server' for glob 'mongo*'
Note, selecting 'mongodb-org-tools' for glob 'mongo*'
Note, selecting 'mongodb-stable' for glob 'mongo*'
Note, selecting 'mongodb-server-core' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable-enterprise-shell' for glob 'mongo*'
Note, selecting 'mongodb-enterprise-unstable-shell' for glob 'mongo*'
Note, selecting 'mongo-10gen-enterprise' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable-mongos' for glob 'mongo*'
Note, selecting 'mongo-tools' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable-enterprise-mongos' for glob 'mongo*'
Note, selecting 'mongodb-enterprise-tools' for glob 'mongo*'
Note, selecting 'mongodb-nightly' for glob 'mongo*'
Note, selecting 'mongo18-10gen-server' for glob 'mongo*'
Note, selecting 'mongodb-org-unstable-server' for glob 'mongo*'
Note, selecting 'mongodb-org-unstable-shell' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable-enterprise-tools' for glob 'mongo*'
Note, selecting 'mongo20-10gen-server' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable' for glob 'mongo*'
Note, selecting 'mongodb-org-shell' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable-tools' for glob 'mongo*'
Note, selecting 'mongodb-enterprise' for glob 'mongo*'
Note, selecting 'mongodb-server' for glob 'mongo*'
Note, selecting 'mongodb-org-unstable-mongos' for glob 'mongo*'
Note, selecting 'mongodb-dev' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable-enterprise-server' for glob 'mongo*'
Note, selecting 'mongodb-10gen' for glob 'mongo*'
Note, selecting 'mongodb-10gen-enterprise' for glob 'mongo*'
Note, selecting 'mongodb-enterprise-shell' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable-tools' for glob 'mongo*'
Note, selecting 'mongodb-enterprise-unstable-server' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable-enterprise-shell' for glob 'mongo*'
Note, selecting 'mongodb-enterprise-unstable' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable-mongos' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable-server' for glob 'mongo*'
Note, selecting 'mongodb-org-unstable' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable-enterprise-mongos' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable-shell' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable-enterprise' for glob 'mongo*'
Note, selecting 'mongodb-org' for glob 'mongo*'
Note, selecting 'mongodb-enterprise-unstable-mongos' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable' for glob 'mongo*'
Note, selecting 'mongodb-clients' for glob 'mongo*'
Note, selecting 'mongo-10gen-server' for glob 'mongo*'
Note, selecting 'mongo-10gen-enterprise-server' for glob 'mongo*'
Note, selecting 'mongodb-org-server' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable-enterprise-tools' for glob 'mongo*'
Note, selecting 'mongodb-enterprise-server' for glob 'mongo*'
Note, selecting 'mongodb-enterprise-unstable-tools' for glob 'mongo*'
Note, selecting 'mongodb-10gen-unstable-enterprise' for glob 'mongo*'
Note, selecting 'mongo-10gen-unstable-shell' for glob 'mongo*'
Note, selecting 'mongo-10gen' for glob 'mongo*'
Note, selecting 'mongodb20-10gen' for glob 'mongo*'
Package 'mongo-10gen' is not installed, so not removed
Package 'mongo-10gen-enterprise' is not installed, so not removed
Package 'mongo-10gen-enterprise-server' is not installed, so not removed
Package 'mongo-10gen-server' is not installed, so not removed
Package 'mongo-10gen-unstable' is not installed, so not removed
Package 'mongo-10gen-unstable-enterprise' is not installed, so not removed
Package 'mongo-10gen-unstable-enterprise-mongos' is not installed, so not removed
Package 'mongo-10gen-unstable-enterprise-server' is not installed, so not removed
Package 'mongo-10gen-unstable-enterprise-shell' is not installed, so not removed
Package 'mongo-10gen-unstable-enterprise-tools' is not installed, so not removed
Package 'mongo-10gen-unstable-mongos' is not installed, so not removed
Package 'mongo-10gen-unstable-server' is not installed, so not removed
Package 'mongo-10gen-unstable-shell' is not installed, so not removed
Package 'mongo-10gen-unstable-tools' is not installed, so not removed
Package 'mongo18-10gen' is not installed, so not removed
Package 'mongo18-10gen-server' is not installed, so not removed
Package 'mongo20-10gen' is not installed, so not removed
Package 'mongo20-10gen-server' is not installed, so not removed
Package 'mongodb-10gen' is not installed, so not removed
Package 'mongodb-10gen-enterprise' is not installed, so not removed
Package 'mongodb-10gen-unstable' is not installed, so not removed
Package 'mongodb-10gen-unstable-enterprise' is not installed, so not removed
Package 'mongodb-10gen-unstable-enterprise-mongos' is not installed, so not removed
Package 'mongodb-10gen-unstable-enterprise-server' is not installed, so not removed
Package 'mongodb-10gen-unstable-enterprise-shell' is not installed, so not removed
Package 'mongodb-10gen-unstable-enterprise-tools' is not installed, so not removed
Package 'mongodb-10gen-unstable-mongos' is not installed, so not removed
Package 'mongodb-10gen-unstable-server' is not installed, so not removed
Package 'mongodb-10gen-unstable-shell' is not installed, so not removed
Package 'mongodb-10gen-unstable-tools' is not installed, so not removed
Package 'mongodb-enterprise-unstable' is not installed, so not removed
Package 'mongodb-enterprise-unstable-mongos' is not installed, so not removed
Package 'mongodb-enterprise-unstable-server' is not installed, so not removed
Package 'mongodb-enterprise-unstable-shell' is not installed, so not removed
Package 'mongodb-enterprise-unstable-tools' is not installed, so not removed
Package 'mongodb-nightly' is not installed, so not removed
Package 'mongodb-org-mongos' is not installed, so not removed
Package 'mongodb-org-shell' is not installed, so not removed
Package 'mongodb-org-tools' is not installed, so not removed
Package 'mongodb-org-unstable' is not installed, so not removed
Package 'mongodb-org-unstable-mongos' is not installed, so not removed
Package 'mongodb-org-unstable-server' is not installed, so not removed
Package 'mongodb-org-unstable-shell' is not installed, so not removed
Package 'mongodb-org-unstable-tools' is not installed, so not removed
Package 'mongodb-stable' is not installed, so not removed
Package 'mongodb18-10gen' is not installed, so not removed
Package 'mongodb20-10gen' is not installed, so not removed
Package 'mongo-tools' is not installed, so not removed
Package 'mongodb' is not installed, so not removed
Package 'mongodb-clients' is not installed, so not removed
Package 'mongodb-dev' is not installed, so not removed
Package 'mongodb-server' is not installed, so not removed
Package 'mongodb-server-core' is not installed, so not removed
Package 'mongodb-enterprise' is not installed, so not removed
Package 'mongodb-enterprise-mongos' is not installed, so not removed
Package 'mongodb-enterprise-server' is not installed, so not removed
Package 'mongodb-enterprise-shell' is not installed, so not removed
Package 'mongodb-enterprise-tools' is not installed, so not removed
The following package was automatically installed and is no longer required:
  libcurl3
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
  mongodb-org* mongodb-org-server*
0 upgraded, 0 newly installed, 2 to remove and 21 not upgraded.
After this operation, 62.2 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 187143 files and directories currently installed.)
Removing mongodb-org-server (4.0.4) ...
Failed to stop mongod.service: Unit mongod.service not loaded.
invoke-rc.d: initscript mongod, action "stop" failed.
dpkg: error processing package mongodb-org-server (--remove):
 installed mongodb-org-server package pre-removal script subprocess returned error exit status 5
Errors were encountered while processing:
 mongodb-org-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

还尝试重新安装:

~$ sudo apt-get --reinstall install mongodb
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libcurl3
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libboost-program-options1.65.1 libgoogle-perftools4 libpcrecpp0v5 libtcmalloc-minimal4 libyaml-cpp0.5v5
  mongo-tools mongodb-clients mongodb-server mongodb-server-core
The following packages will be REMOVED:
  mongodb-org-server
The following NEW packages will be installed:
  libboost-program-options1.65.1 libgoogle-perftools4 libpcrecpp0v5 libtcmalloc-minimal4 libyaml-cpp0.5v5
  mongo-tools mongodb mongodb-clients mongodb-server mongodb-server-core
0 upgraded, 10 newly installed, 1 to remove and 21 not upgraded.
Need to get 53.4 MB of archives.
After this operation, 154 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 libboost-program-options1.65.1 amd64 1.65.1+dfsg-0ubuntu5 [137 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 libtcmalloc-minimal4 amd64 2.5-2.2ubuntu3 [91.6 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 libgoogle-perftools4 amd64 2.5-2.2ubuntu3 [190 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 libpcrecpp0v5 amd64 2:8.39-9 [15.3 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 libyaml-cpp0.5v5 amd64 0.5.2-4ubuntu1 [150 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 mongo-tools amd64 3.6.3-0ubuntu1 [12.3 MB]
Get:7 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 mongodb-clients amd64 1:3.6.3-0ubuntu1 [20.2 MB]
Get:8 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 mongodb-server-core amd64 1:3.6.3-0ubuntu1 [20.3 MB]
Get:9 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 mongodb-server all 1:3.6.3-0ubuntu1 [12.6 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 mongodb amd64 1:3.6.3-0ubuntu1 [9,892 B]
Fetched 53.4 MB in 5s (11.3 MB/s)    
(Reading database ... 187143 files and directories currently installed.)
Removing mongodb-org-server (4.0.4) ...
Failed to stop mongod.service: Unit mongod.service not loaded.
invoke-rc.d: initscript mongod, action "stop" failed.
dpkg: error processing package mongodb-org-server (--remove):
 installed mongodb-org-server package pre-removal script subprocess returned error exit status 5
Errors were encountered while processing:
 mongodb-org-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

并自动删除:

$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 21 not upgraded.

我很困惑它是否已被完全删除,这就是为什么我收到这些错误,还是无法删除?如果是这样,那么 dpkg 是如何得出要删除的数字 62.2 Mb 的?我是否最好删除整个 Ubuntu 安装并从头开始?有没有关于在 Ubuntu 18.04 上安装 MongoDB 的好的、完整的指南?因为即使为了让我之前损坏的安装部分恢复,我也必须执行官方安装指南中未提及的线程中建议的操作。

编辑:明确的问题是我无法使用 apt-get purge mongo,而且服务甚至没有运行。

~$  sudo service mongod stop
[sudo] password for james: 
Failed to stop mongod.service: Unit mongod.service not loaded.
~$ sudo apt-get purge mongodb-org*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'mongodb-org-unstable-tools' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-mongos' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-tools' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-unstable-server' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-unstable-shell' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-shell' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-unstable-mongos' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-unstable' for glob 'mongodb-org*'
Note, selecting 'mongodb-org' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-server' for glob 'mongodb-org*'
Package 'mongodb-org-mongos' is not installed, so not removed
Package 'mongodb-org-shell' is not installed, so not removed
Package 'mongodb-org-tools' is not installed, so not removed
Package 'mongodb-org-unstable' is not installed, so not removed
Package 'mongodb-org-unstable-mongos' is not installed, so not removed
Package 'mongodb-org-unstable-server' is not installed, so not removed
Package 'mongodb-org-unstable-shell' is not installed, so not removed
Package 'mongodb-org-unstable-tools' is not installed, so not removed
The following package was automatically installed and is no longer required:
  libcurl3
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
  mongodb-org* mongodb-org-server*
0 upgraded, 0 newly installed, 2 to remove and 21 not upgraded.
After this operation, 62.2 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 187143 files and directories currently installed.)
Removing mongodb-org-server (4.0.4) ...
Failed to stop mongod.service: Unit mongod.service not loaded.
invoke-rc.d: initscript mongod, action "stop" failed.
dpkg: error processing package mongodb-org-server (--remove):
 installed mongodb-org-server package pre-removal script subprocess returned error exit status 5
Errors were encountered while processing:
 mongodb-org-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

强制删除也不起作用:

~$ sudo apt-get autoclean
Reading package lists... Done
Building dependency tree       
Reading state information... Done
~$ sudo apt-get --force-yes remove  mongodb-org-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libcurl3
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
  mongodb-org-server
0 upgraded, 0 newly installed, 1 to remove and 21 not upgraded.
After this operation, 62.2 MB disk space will be freed.
W: --force-yes is deprecated, use one of the options starting with --allow instead.
Do you want to continue? [Y/n] y
(Reading database ... 187143 files and directories currently installed.)
Removing mongodb-org-server (4.0.4) ...
Failed to stop mongod.service: Unit mongod.service not loaded.
invoke-rc.d: initscript mongod, action "stop" failed.
dpkg: error processing package mongodb-org-server (--remove):
 installed mongodb-org-server package pre-removal script subprocess returned error exit status 5
Errors were encountered while processing:
 mongodb-org-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
~$ sudo dpkg --purge --force-all  mongodb-org-server
(Reading database ... 187143 files and directories currently installed.)
Removing mongodb-org-server (4.0.4) ...
Failed to stop mongod.service: Unit mongod.service not loaded.
invoke-rc.d: initscript mongod, action "stop" failed.
dpkg: error processing package mongodb-org-server (--purge):
 installed mongodb-org-server package pre-removal script subprocess returned error exit status 5
Errors were encountered while processing:
 mongodb-org-server

答案1

事实证明,/var/lib/dpkg/info 中有一些与 mongdb 相关的文件,一旦删除,清除就可以成功完成。我对 mongoDB 文档非常生气,因为它建议他们的软件包比操作系统存储库维护得更好,我应该从他们的存储库安装。

相关内容