MongoDB在本地运行,但在尝试远程访问时失败

时间:2015-01-10 15:30:39

标签: mongodb

能够在本地运行MongoDB,但在尝试远程访问时失败了。没有做任何防火墙设置。可能是什么问题?如何排除故障?

MongoDB状态显示正在运行

service mongod status
mongod (pid 25342) is running...

但是当试图重新启动服务时,它说

service mongod restart
Stopping mongod:                                           [  OK  ]
Starting mongod:                                           [FAILED]

但是这个过程仍在运行

更新

尝试mongod --repair这里是更新

2015-01-10T10:46:33.109-0500 [initandlisten] MongoDB starting : pid=29018 port=2                                                                                        7017 dbpath=/data/db 64-bit host=ns4008927.ip-192-99-3.net
2015-01-10T10:46:33.109-0500 [initandlisten] db version v2.6.6
2015-01-10T10:46:33.109-0500 [initandlisten] git version: 608e8bc319627693b04cc7                                                                                        da29ecc300a5f45a1f
2015-01-10T10:46:33.109-0500 [initandlisten] build info: Linux build10.nj1.10gen                                                                                        .cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LI                                                                                        B_VERSION=1_49
2015-01-10T10:46:33.109-0500 [initandlisten] allocator: tcmalloc
2015-01-10T10:46:33.109-0500 [initandlisten] options: { repair: true }
2015-01-10T10:46:33.112-0500 [initandlisten] finished checking dbs
2015-01-10T10:46:33.112-0500 [initandlisten] dbexit:
2015-01-10T10:46:33.112-0500 [initandlisten] shutdown: going to close listening                                                                                         sockets...
2015-01-10T10:46:33.112-0500 [initandlisten] shutdown: going to flush diaglog...
2015-01-10T10:46:33.112-0500 [initandlisten] shutdown: going to close sockets...
2015-01-10T10:46:33.112-0500 [initandlisten] shutdown: waiting for fs preallocat                                                                                        or...
2015-01-10T10:46:33.112-0500 [initandlisten] shutdown: closing all files...
2015-01-10T10:46:33.112-0500 [initandlisten] closeAllFiles() finished
2015-01-10T10:46:33.112-0500 [initandlisten] shutdown: removing fs lock...
2015-01-10T10:46:33.112-0500 [initandlisten] dbexit: really exiting now

1 个答案:

答案 0 :(得分:1)

你需要从mongo的配置文件中删除这一行(在Ubuntu上,我的是/etc/mongod.conf):

bind_ip = 127.0.0.1

或者,如果它是YAML,

bindIp: 127.0.0.1

来源:http://docs.mongodb.org/manual/reference/configuration-options/

“在2.6.0版本中更改:deb和rpm软件包包含一个默认配置文件,用于将net.bindIp设置为127.0.0.1。”

bindIp / bind_ip的默认值是“所有接口” - 这样删除就派上用场了。