安装MongoDB时发生冲突

安装MongoDB时发生冲突

我有一台 CentOS 7 的服务器,我想安装 mongoDB。我尝试安装它,输入:

sudo yum install mongodb

没有任何问题,那么我mongod得到:

-bash: mongod: command not found

如果我这样做,mongo我只会得到:

2017-04-22T21:09:55.078+0000 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2017-04-22T21:09:55.079+0000 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146

因此,我尝试按照以下方法再次安装本说明但当我输入时 sudo yum install -y mongodb-org我得到:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.constant.com
 * epel: mirror.math.princeton.edu
 * extras: mirror.netdepot.com
 * updates: mirror.cc.columbia.edu
Resolving Dependencies
--> Running transaction check
---> Package mongodb-org.x86_64 0:3.4.4-1.el7 will be installed
--> Processing Dependency: mongodb-org-tools = 3.4.4 for package: mongodb-org-3.4.4-1.el7.x86_64
--> Processing Dependency: mongodb-org-shell = 3.4.4 for package: mongodb-org-3.4.4-1.el7.x86_64
--> Processing Dependency: mongodb-org-server = 3.4.4 for package: mongodb-org-3.4.4-1.el7.x86_64
--> Processing Dependency: mongodb-org-mongos = 3.4.4 for package: mongodb-org-3.4.4-1.el7.x86_64
--> Running transaction check
---> Package mongodb-org-mongos.x86_64 0:3.4.4-1.el7 will be installed
---> Package mongodb-org-server.x86_64 0:3.4.4-1.el7 will be installed
---> Package mongodb-org-shell.x86_64 0:3.4.4-1.el7 will be installed
---> Package mongodb-org-tools.x86_64 0:3.4.4-1.el7 will be installed
--> Processing Conflict: mongodb-org-server-3.4.4-1.el7.x86_64 conflicts mongodb
--> Processing Conflict: mongodb-org-3.4.4-1.el7.x86_64 conflicts mongodb
--> Processing Conflict: mongodb-org-shell-3.4.4-1.el7.x86_64 conflicts mongodb
--> Processing Conflict: mongodb-org-mongos-3.4.4-1.el7.x86_64 conflicts mongodb
--> Processing Conflict: mongodb-org-tools-3.4.4-1.el7.x86_64 conflicts mongodb
--> Finished Dependency Resolution
Error: mongodb-org-mongos conflicts with mongodb-2.6.12-4.el7.x86_64
Error: mongodb-org-shell conflicts with mongodb-2.6.12-4.el7.x86_64
Error: mongodb-org-tools conflicts with mongodb-2.6.12-4.el7.x86_64
Error: mongodb-org conflicts with mongodb-2.6.12-4.el7.x86_64
Error: mongodb-org-server conflicts with mongodb-2.6.12-4.el7.x86_64
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

这让我抓狂。我读到yum makecache重新安装可以解决我的问题,但并没有。还尝试卸载所有内容, sudo yum erase $(rpm -qa | grep mongodb-org)但结果却显示:

Loaded plugins: fastestmirror
Error: Need to pass a list of pkgs to erase
 Mini usage:

erase PACKAGE...

Remove a package or packages from your system

aliases: remove, autoremove, erase-n, erase-na, erase-nevra, autoremove-n, autoremove-na, autoremove-nevra, remove-n, remove-na, remove-nevra

那么,我还能做什么?我只需要运行 mongo。谢谢!

答案1

您已经mongodb-2.6.12-4.el7.x86_64安装(最有可能来自 EPEL 仓库 - 我只是猜测,因为您没有指定)并正在尝试从 MongoDB 仓库安装另一个版本。

请尝试以下操作:

yum remove mongodb*
yum clean all
yum install mongodb-org

不要使用-yyum花点时间阅读屏幕上的内容,尤其是对你来说很新的内容。

相关内容