mongodb Mongo:尝试在主机上运行命令“whatsmyuri”时出现网络错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35509937/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mongo: network error while attempting to run command 'whatsmyuri' on host
提问by makeMonday
I have been trying to access my mongo instance from another machine, but I get this error. I could not find many references to this whatsmyuri
error. This is what I get from the external machine:
我一直在尝试从另一台机器访问我的 mongo 实例,但出现此错误。我找不到很多对此whatsmyuri
错误的引用。这是我从外部机器得到的:
$ mongo <IP_ADDRESS>:27017/youtube_advertising -u user -p password
MongoDB shell version: 3.2.0
connecting to: <IP_ADDRESS>:27017/youtube_advertising
2016-02-19T17:10:02.923+0100 E QUERY [thread1] Error: network error while attempting to run command 'whatsmyuri' on host '<IP_ADDRESS>:27017' :
connect@src/mongo/shell/mongo.js:226:14
@(connect):1:6
exception: connect failed
I have already changed the /etc/mongod.conf
file, opened connections through port 27017
(with iptables
) and restarted mongo. I am able to connect via ssh
to that machine.
我已经更改了/etc/mongod.conf
文件,通过端口27017
(使用iptables
)打开了连接并重新启动了 mongo。我能够通过连接到那ssh
台机器。
Searching about this whatsmyuri
, I ran this command on mongo:
搜索这个whatsmyuri
,我在 mongo 上运行了这个命令:
> db.runCommand( { whatsmyuri: 1 } )
{ "you" : "127.0.0.1:36990", "ok" : 1 }
I do not know if that 36990
port is right or wrong. Just in case I opened connections from there too, but still nothing.
我不知道那个36990
端口是对还是错。以防万一我也从那里打开了连接,但仍然没有。
Any ideas?
有任何想法吗?
UPDATE
更新
Checking the /var/log/mongodb/mongod.log
, this is what I get when I try to connect from remote:
检查/var/log/mongodb/mongod.log
,这是我尝试从远程连接时得到的结果:
2016-02-19T10:41:07.292-0600 I NETWORK [initandlisten] connection accepted from <EXT_IP_ADDRESS>:51800 #2 (1 connection now open)
2016-02-19T10:41:07.310-0600 I QUERY [conn2] operation isn't supported: 2010
2016-02-19T10:41:07.310-0600 I - [conn2] Assertion: 16141:cannot translate opcode 2010
回答by rahul
Check your versions. That may help.
检查您的版本。这可能会有所帮助。
I was having the same problem. In my case, the server was version 3.2.0-rc2, while mongo shell version was 3.2.1.
我遇到了同样的问题。就我而言,服务器版本为 3.2.0-rc2,而 mongo shell 版本为 3.2.1。
Upgrading the server to 3.2.1 fixed the problem.
将服务器升级到 3.2.1 解决了这个问题。
回答by Jeff Mather
This issue bit me when I was running two versions (3.4 and 4.2) of MongoDB on the same Windows 10 machine. I ran v3.4 mongod with no problems mentioned in the console output, but then running the v3.4 mongo shell produced the above error. Checking the Task Manager, it turned out there was a MongoDB process (I'm not sure, but I think it was for v4.2) running. After ending that process through the Task Manager, the v3.4 mongo shell ran fine with no error.
当我在同一台 Windows 10 机器上运行两个版本(3.4 和 4.2)的 MongoDB 时,这个问题困扰着我。我运行了 v3.4 mongod,控制台输出中没有提到任何问题,但是运行 v3.4 mongo shell 产生了上述错误。检查任务管理器,结果发现有一个 MongoDB 进程(我不确定,但我认为它适用于 v4.2)正在运行。通过任务管理器结束该过程后,v3.4 mongo shell 运行良好,没有错误。
回答by dscanon
Using mongodb-community-shell
使用 mongodb-community-shell
In MacOs brew install mongodb/brew/mongodb-community-shell
在 MacOs 中 brew install mongodb/brew/mongodb-community-shell
It will ask you to overwrite link with mongo command.
它会要求您使用 mongo 命令覆盖链接。
brew link --overwrite mongodb-community-shell
brew link --overwrite mongodb-community-shell