2017-08-25 103 views
-1

這是我正在做的解決問題的方法請查看並告訴我發生了什麼問題。我刪除了mongod.lock文件,然後cd回來運行./mongod,但仍然無法工作。mongodb在意外崩潰後未啓動

oxmat:~ $ cd data 
oxmat:~/data $ ls 
local/ local.0 local.ns mongod.lock* restfull_blogapp/ restfull_blogapp.0 restfull_blogapp.ns yelp_camp/ yelp_camp.0 yelp_camp.ns 
oxmat:~/data $ rm mongod.lock 
oxmat:~/data $ ls 
local/ local.0 local.ns restfull_blogapp/ restfull_blogapp.0 restfull_blogapp.ns yelp_camp/ yelp_camp.0 yelp_camp.ns 
oxmat:~/data $ cd .. 
oxmat:~ $ ./mongod 
2017-08-25T11:58:50.766+0000 ** WARNING: --rest is specified without --httpinterface, 
2017-08-25T11:58:50.766+0000 **   enabling http interface 
warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default 
2017-08-25T11:58:50.770+0000 [initandlisten] MongoDB starting : pid=5842 port=27017 dbpath=data 64-bit host=oxmat-oxmat-5130321 
2017-08-25T11:58:50.770+0000 [initandlisten] db version v2.6.12 
2017-08-25T11:58:50.770+0000 [initandlisten] git version: d73c92b1c85703828b55c2916a5dd4ad46535f6a 
2017-08-25T11:58:50.770+0000 [initandlisten] build info: Linux build5.ny.cbi.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49 
2017-08-25T11:58:50.770+0000 [initandlisten] allocator: tcmalloc 
2017-08-25T11:58:50.770+0000 [initandlisten] options: { net: { bindIp: "0.0.0.0", http: { RESTInterfaceEnabled: true, enabled: true } }, storage: { dbPath: "data", journal: { enabled: false } } } 
2017-08-25T11:58:50.779+0000 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017 
2017-08-25T11:58:50.779+0000 [initandlisten] ERROR: addr already in use 
2017-08-25T11:58:50.779+0000 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017 
2017-08-25T11:58:50.779+0000 [initandlisten] ERROR: addr already in use 
2017-08-25T11:58:50.780+0000 [initandlisten] now exiting 
2017-08-25T11:58:50.780+0000 [initandlisten] dbexit: 
2017-08-25T11:58:50.780+0000 [initandlisten] shutdown: going to close listening sockets... 
2017-08-25T11:58:50.780+0000 [initandlisten] shutdown: going to flush diaglog... 
2017-08-25T11:58:50.780+0000 [initandlisten] shutdown: going to close sockets... 
2017-08-25T11:58:50.780+0000 [initandlisten] shutdown: waiting for fs preallocator... 
2017-08-25T11:58:50.780+0000 [initandlisten] shutdown: closing all files... 
2017-08-25T11:58:50.780+0000 [initandlisten] closeAllFiles() finished 
2017-08-25T11:58:50.780+0000 [initandlisten] shutdown: removing fs lock... 
2017-08-25T11:58:50.780+0000 [initandlisten] dbexit: really exiting now 
oxmat:~ $ 
+0

如果您試圖在Cloud9的未付費實例上啓動MongoDB,那麼我幾乎不會將崩潰稱爲「意外」。這更像是「當這不可避免發生的!」。數據庫比那裏提供的小型實例產品要多得多。與其試圖在基於虛擬機的IDE和開發測試平臺中啓動數據庫引擎,不如嘗試註冊免費的MongoDB託管服務。現在有不止兩個提供者,而且開發環境中唯一的負載是連接字符串。 –

回答

0

消息

ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017 

意味着什麼已經綁定到端口27017這也可能是另一個mongod的實例。

運行ps -e | grep 'mongo'查看是否有mongod進程。例如,我得到輸出:

48298 ttys000 1:14.83 mongod 

因此,您可以使用該輸出中的進程ID終止進程。在這個例子中,進程ID是48298,所以我終止它與kill 48298

然後嘗試再次運行mongod。

如果由於某種原因,某個其他進程正在使用端口27017,則可以通過指定--port標誌來使用不同的端口,如下所示。

./mongod --port 12345