0

当我尝试使用“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”不是吗?

更新 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;
> 
4

3 回答 3

3

是否有其他进程正在侦听这些端口?尝试找出:

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

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

于 2013-10-29T12:24:25.650 回答
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 实例,而是使用该端口的其他一些应用程序。

于 2013-10-29T12:22:14.920 回答
0

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

于 2016-01-04T05:13:59.823 回答