shell - MongoDB 正在运行但无法使用 shell 连接

CentOS 5.x Linux 和 MongoDB 2.0.1(尝试过 main 和 legacy-static)

MongoDB 正在运行:

root     31664  1.5  1.4  81848 11148 ?        Sl   18:40   0:00 ./mongod -f mongo.conf -vvvvv --fork

使用简单的 shell 连接到服务器失败:

[root@xxxx bin]# ./mongo
MongoDB shell version: 2.0.1
connecting to: test
Mon Oct 31 18:41:32 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed

端口 28017 上的 Web 界面可以正常加载,就像使用远程 Linux 主机上的 MongoDB shell 一样。也可以 telnet 到 localhost:27017,这意味着没有端口被阻塞。这台机器上也没有运行 SELinux。我也尝试过明确指定 localhost:2017/db 无济于事。

$ ./mongo remote-ip:27017
MongoDB shell version: 2.0.1
connecting to: remote-ip:27017/test
> show dbs
local   0.03125GB
>

日志完全没有关于这个主题:

.....
Mon Oct 31 18:40:34 [initandlisten] fd limit hard:1024 soft:1024 max conn: 819
Mon Oct 31 18:40:34 [initandlisten] waiting for connections on port 27017
Mon Oct 31 18:40:34 BackgroundJob starting: snapshot
Mon Oct 31 18:40:34 BackgroundJob starting: ClientCursorMonitor
Mon Oct 31 18:40:34 BackgroundJob starting: PeriodicTask::Runner
Mon Oct 31 18:40:34 [websvr] fd limit hard:1024 soft:1024 max conn: 819
Mon Oct 31 18:40:34 [websvr] admin web console waiting for connections on port 28017

跟踪 mongo shell 客户端只显示一个有问题的调用:

[pid 31708] connect(4, {sa_family=AF_INET, sin_port=htons(27017), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EBADF (Bad file descriptor)

文件系统干净,没有 ulimit 限制(以 root 身份运行以进行测试)。我可以从 strace 中看到 mongo 客户端正在尝试通过 TCP (AF_INET) 进行连接,但是由于它是本地的并且 MongoDB 创建了一个文件套接字,有没有办法告诉客户端通过那个连接?或者更好的是,为什么客户会抛出 EBADF?

编辑:我的基本 Mongo 配置:

dbpath=/root/mongodb-linux-i686-2.0.1/data
logpath=/root/mongodb-linux-i686-2.0.1/logs/mongo.log
slowms=15
rest=1

最佳答案

我认为这个版本的 mongoDb 客户端缺少一些默认配置。尝试运行:

mongo 127.0.0.1:27017

这很奇怪,但后来我遇到了这个问题:)(所以没有任何参数的简单命令 'mongo' 再次开始为我工作)

[Ubuntu Linux 11.10 x64 / MongoDB 2.0.1]

https://stackoverflow.com/questions/7958228/

相关文章:

ruby-on-rails - Mongoid 3 + Heroku (MongoHQ) 导致 Mo

node.js - 如何在 Mongoose 中执行 id 数组查询?

mongodb - 在单个查询中从 mongo 中删除多个文档

php - Mongodb php获取新文档的ID?

mongodb - 在MongoDB中获取数组的第n个元素

mongodb - 在键值数据存储中存储目录层次结构

mongodb - mongoexport 聚合导出到 csv 文件

mongodb - 在 MongoDB 中存储日期的最佳方式是什么?

ubuntu - MongoDB 仅在 Ubuntu 上以 root 身份运行时才有效 - 数据目录

javascript - 如何在 Mongoose 模型中定义方法?