mongo shell没有连接到正确的IP和端口 - ubuntu

时间:2015-07-18 21:32:57

标签: node.js mongodb ubuntu

Ubuntu 14.04上出现此问题

我能够更改我的mongod.conf文件以包含不同的bind_ip和端口。 当我使用配置文件调用mongod时,日志会完美地列出ip和端口。像这样:

(端口为24141,IP为10.132.44.332)

***** SERVER RESTARTED *****


Sat Jul 18 17:23:05.119 [initandlisten] MongoDB starting : pid=9285 port=24141 dbpath=/var/lib/mongodb 64-bit host=web
Sat Jul 18 17:23:05.119 [initandlisten] db version v2.4.14
Sat Jul 18 17:23:05.119 [initandlisten] git version: 05bebf9ab15511a71bfbded684bb226014c0a553
Sat Jul 18 17:23:05.119 [initandlisten] build info: Linux ip-10-154-253-119 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Sat Jul 18 17:23:05.119 [initandlisten] allocator: tcmalloc
Sat Jul 18 17:23:05.120 [initandlisten] options: { bind_ip: "10.132.44.332", config: "/etc/mongod.conf", dbpath: "/var/lib/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongod.log", port: 24141 }
Sat Jul 18 17:23:05.123 [initandlisten] journal dir=/var/lib/mongodb/journal
Sat Jul 18 17:23:05.123 [initandlisten] recover : no journal files present, no recovery needed
Sat Jul 18 17:23:05.204 [initandlisten] waiting for connections on port 24141
Sat Jul 18 17:23:05.205 [websvr] admin web console waiting for connections on port 25141

虽然,当我去运行mongo时,我得到:

MongoDB shell version: 2.4.14
connecting to: test
Sat Jul 18 17:30:33.112 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed

是的,在你将这个问题标记为重复之前,我知道很多人都遇到过这个问题,但是我还没有看到端口没有同步的地方?

我已经尝试过--repair并重新启动和一堆chmod东西来修复它,但没有骰子。有没有人对如何让两者相同有任何想法?

1 个答案:

答案 0 :(得分:1)

尝试使用--port [X]运行mongo,其中x是您想要连接的所需端口。

mongo --port 24141