2013-10-29 117 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默認實例並使其版本啓動並運行