启动mongo失败

时间:2013-10-29 12:18:11

标签: mongodb

当我尝试使用“mongod”命令(在Macintosh上)启动mongo时出现错误。

all output going to: /usr/local/var/log/mongodb/mongo.log

我的日志:

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


Tue Oct 29 13:15:48.783 [initandlisten] MongoDB starting : pid=859 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=MacBook-Pro-de-Anthony
Tue Oct 29 13:15:48.784 [initandlisten] db version v2.4.4
Tue Oct 29 13:15:48.784 [initandlisten] git version: 4ec1fb96702c9d4c57b1e06dd34eb73a16e407d2
Tue Oct 29 13:15:48.784 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Tue Oct 29 13:15:48.784 [initandlisten] allocator: system
Tue Oct 29 13:15:48.784 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log" }
Tue Oct 29 13:15:48.784 [initandlisten] journal dir=/usr/local/var/mongodb/journal
Tue Oct 29 13:15:48.784 [initandlisten] recover : no journal files present, no recovery needed
Tue Oct 29 13:15:48.801 [initandlisten] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 127.0.0.1:27017
Tue Oct 29 13:15:48.801 [websvr] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 127.0.0.1:28017
Tue Oct 29 13:15:48.801 [initandlisten] ERROR:   addr already in use
Tue Oct 29 13:15:48.801 [websvr] ERROR:   addr already in use
Tue Oct 29 13:15:48.801 [initandlisten] now exiting
Tue Oct 29 13:15:48.801 dbexit: 
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: going to close listening sockets...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: going to flush diaglog...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: going to close sockets...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: waiting for fs preallocator...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: lock for final commit...
Tue Oct 29 13:15:48.801 [initandlisten] shutdown: final commit...
Tue Oct 29 13:15:48.802 [initandlisten] shutdown: closing all files...
Tue Oct 29 13:15:48.802 [initandlisten] closeAllFiles() finished
Tue Oct 29 13:15:48.802 [initandlisten] journalCleanup...
Tue Oct 29 13:15:48.802 [initandlisten] removeJournalFiles
Tue Oct 29 13:15:48.803 [initandlisten] shutdown: removing fs lock...
Tue Oct 29 13:15:48.803 dbexit: really exiting now

更新:

当我执行“mongo”命令时:

MacBook-Pro-de-Anthony:Sites anthonycluse$ mongo
MongoDB shell version: 2.4.4
connecting to: test
Server has startup warnings: 
Tue Oct 29 11:43:15 [initandlisten] 
Tue Oct 29 11:43:15 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> show dbs;
anthonycluse    (empty)
local   (empty)
> 

这意味着用户名是“test”no?

更新2:

“显示用户”;命令:

MacBook-Pro-de-Anthony:Sites anthonycluse$ mongo
MongoDB shell version: 2.4.4
connecting to: test
Server has startup warnings: 
Tue Oct 29 11:43:15 [initandlisten] 
Tue Oct 29 11:43:15 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
> show users;
> 

3 个答案:

答案 0 :(得分:3)

是否还有另一个进程侦听这些端口?尝试找出:

netstat -tulpen | grep 017 # 017 for both port 27017 and 28017

如果您确定不需要,请终止该过程。如下面Lix所述,可能已经有一个mongo进程在运行。

答案 1 :(得分:1)

答案就在日志文件旁边:

Tue Oct 29 13:15:48.801 [websvr] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 127.0.0.1:28017

特别是这部分:"Address already in use for socket: 127.0.0.1:28017"

似乎已经在默认端口27017上运行了mongo实例。它甚至可能不是mongo实例,而是使用该端口的其他应用程序。

答案 2 :(得分:0)

根据日志很明显,默认情况下运行另一个mongodb实例,我相信您使用rpm安装了mongodb并使用服务mongodb start启动了此服务。因此,当服务器默认重启时,它会启动一些服务,使用defaultconfiguration,可以在/etc/mongod.config中编辑这个文件或者停止已经运行的文件,这样你就可以避免mongod默认instamce并制作你的版本了启动并运行