2013-10-29 124 views
0

当我尝试使用“mongod”命令(Macintosh)启动mongo时出现错误。启动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 

UPDATE:

当我执行 “蒙戈” 命令:

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) 
> 

这意味着,用户名是 “测试” 没有?

UPDATE 2:

“show users;”命令:

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; 
> 
+0

两个需要的端口(27017,28017)似乎已被使用。你确定服务尚未开始? – GolfWolf

+0

Nope - test是默认数据库的名称。 – Lix

+0

是否有命令显示当前用户名?这是我的电脑...在本地... – tonymx227

回答

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实例,而是使用该端口的其他应用程序。

+0

好吧,但我在哪里可以看到我的用户名和密码? (本地主机) – tonymx227

+0

恩......呵呵?什么用户名和密码?对于蒙戈? – Lix

+0

是的,就像mongo的根目录mysql bur ... – tonymx227

3

是否有另一个进程监听这些端口?试着找出:

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

如果你确定你不需要它,就终止这个过程。正如Lix在下面回答的那样,可能已经有一个mongo进程在运行。

0

根据日志显然,有另一个mongodb实例运行在默认情况下,我相信你使用rpm安装了mongodb并使用服务mongodb start启动了此服务。所以当服务器默认重新启动时,它会启动一些服务,使用默认配置,这将在/etc/mongod.config中可用,编辑此文件或停止正在运行的服务,这样可以避免使用mongod默认实例并使其版本启动并运行