2013-12-22 60 views
1

當我啓動mongod trowed錯誤。問題是什麼?mongod shell不啓動,data/db不存在

[email protected]:~# mongod 
mongod --help for help and startup options 
Sun Dec 22 15:37:44.081 [initandlisten] MongoDB starting : pid=18415 port=27017 dbpath=/data/db/ 64-bit host=cs12867 
Sun Dec 22 15:37:44.081 [initandlisten] db version v2.4.6 
Sun Dec 22 15:37:44.081 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673 
Sun Dec 22 15:37:44.081 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49 
Sun Dec 22 15:37:44.081 [initandlisten] allocator: tcmalloc 
Sun Dec 22 15:37:44.081 [initandlisten] options: {} 
Sun Dec 22 15:37:44.081 [initandlisten] exception in initAndListen: 10296 
********************************************************************* 
ERROR: dbpath (/data/db/) does not exist. 
Create this directory or give existing directory in --dbpath. 
See http://dochub.mongodb.org/core/startingandstoppingmongo 
********************************************************************* 
, terminating 
Sun Dec 22 15:37:44.081 dbexit: 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close listening sockets... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to flush diaglog... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close sockets... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: waiting for fs preallocator... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: lock for final commit... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: final commit... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: closing all files... 
Sun Dec 22 15:37:44.081 [initandlisten] closeAllFiles() finished 
Sun Dec 22 15:37:44.081 dbexit: really exiting now 

我設置--dbpath

[email protected]:~# mongod --dbpath /var/lib/mongodb/data/db 
Sun Dec 22 15:29:25.121 [initandlisten] MongoDB starting : pid=17739 port=27017 dbpath=/var/lib/mongodb/data/db 64-bit host=cs12867 
Sun Dec 22 15:29:25.121 [initandlisten] db version v2.4.6 
Sun Dec 22 15:29:25.121 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673 
Sun Dec 22 15:29:25.121 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49 
Sun Dec 22 15:29:25.121 [initandlisten] allocator: tcmalloc 
Sun Dec 22 15:29:25.121 [initandlisten] options: { dbpath: "/var/lib/mongodb/data/db" } 
Sun Dec 22 15:29:25.121 [initandlisten] 
Sun Dec 22 15:29:25.121 [initandlisten] ** WARNING: Readahead for /var/lib/mongodb/data/db is set to 2048KB 
Sun Dec 22 15:29:25.121 [initandlisten] **   We suggest setting it to 256KB (512 sectors) or less 
Sun Dec 22 15:29:25.121 [initandlisten] **   http://dochub.mongodb.org/core/readahead 
Sun Dec 22 15:29:25.123 [initandlisten] journal dir=/var/lib/mongodb/data/db/journal 
Sun Dec 22 15:29:25.123 [initandlisten] recover : no journal files present, no recovery needed 
Sun Dec 22 15:29:25.134 [initandlisten] waiting for connections on port 27017 
Sun Dec 22 15:29:25.134 [websvr] admin web console waiting for connections on port 28017 
Sun Dec 22 15:29:26.179 [initandlisten] connection accepted from 127.0.0.1:37164 #1 (1 connection now open) 
Sun Dec 22 15:29:26.179 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.ns, filling with zeroes... 
Sun Dec 22 15:29:26.179 [FileAllocator] creating directory /var/lib/mongodb/data/db/_tmp 
Sun Dec 22 15:29:26.181 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.ns, size: 16MB, took 0 secs 
Sun Dec 22 15:29:26.181 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.0, filling with zeroes... 
Sun Dec 22 15:29:26.181 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.0, size: 64MB, took 0 secs 
Sun Dec 22 15:29:26.182 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.1, filling with zeroes... 
Sun Dec 22 15:29:26.182 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.1, size: 128MB, took 0 secs 
Sun Dec 22 15:29:26.184 [conn1] build index Tester.user { _id: 1 } 
Sun Dec 22 15:29:26.184 [conn1] build index done. scanned 0 total records. 0 secs 
Sun Dec 22 15:29:26.184 [conn1] end connection 127.0.0.1:37164 (0 connections now open) 
Sun Dec 22 15:29:26.192 [initandlisten] connection accepted from 127.0.0.1:37165 #2 (1 connection now open) 
Sun Dec 22 15:29:26.732 [initandlisten] connection accepted from 127.0.0.1:37166 #3 (2 connections now open) 
Sun Dec 22 15:29:26.733 [conn3] end connection 127.0.0.1:37166 (1 connection now open) 
Sun Dec 22 15:29:26.740 [initandlisten] connection accepted from 127.0.0.1:37167 #4 (2 connections now open) 
Sun Dec 22 15:29:26.740 [conn4] end connection 127.0.0.1:37167 (1 connection now open) 
Sun Dec 22 15:29:26.834 [initandlisten] connection accepted from 127.0.0.1:37168 #5 (2 connections now open) 
Sun Dec 22 15:29:26.835 [conn5] end connection 127.0.0.1:37168 (1 connection now open) 
Sun Dec 22 15:29:26.843 [initandlisten] connection accepted from 127.0.0.1:37169 #6 (2 connections now open) 
Sun Dec 22 15:29:27.252 [initandlisten] connection accepted from 127.0.0.1:37170 #7 (3 connections now open) 
Sun Dec 22 15:29:27.253 [conn7] end connection 127.0.0.1:37170 (2 connections now open) 
Sun Dec 22 15:29:27.304 [initandlisten] connection accepted from 127.0.0.1:37171 #8 (3 connections now open) 
Sun Dec 22 15:29:27.304 [conn8] end connection 127.0.0.1:37171 (2 connections now open) 
Sun Dec 22 15:29:28.332 [initandlisten] connection accepted from 127.0.0.1:37173 #9 (3 connections now open) 
Sun Dec 22 15:29:28.333 [conn9] end connection 127.0.0.1:37173 (2 connections now open) 
Sun Dec 22 15:29:28.352 [initandlisten] connection accepted from 127.0.0.1:37174 #10 (3 connections now open) 
Sun Dec 22 15:29:28.842 [conn10] end connection 127.0.0.1:37174 (2 connections now open) 
Sun Dec 22 15:29:28.862 [initandlisten] connection accepted from 127.0.0.1:37176 #11 (3 connections now open) 
Sun Dec 22 15:29:28.863 [conn11] end connection 127.0.0.1:37176 (2 connections now open) 
Sun Dec 22 15:29:30.362 [initandlisten] connection accepted from 127.0.0.1:37178 #12 (3 connections now open) 
Sun Dec 22 15:29:30.363 [initandlisten] connection accepted from 127.0.0.1:37179 #13 (4 connections now open) 
Sun Dec 22 15:29:30.364 [conn13] end connection 127.0.0.1:37179 (3 connections now open) 
Sun Dec 22 15:37:36.523 [signalProcessingThread] shutdown: closing all files... 
Sun Dec 22 15:37:36.523 [signalProcessingThread] closeAllFiles() finished 
Sun Dec 22 15:37:36.523 [signalProcessingThread] journalCleanup... 
Sun Dec 22 15:37:36.523 [signalProcessingThread] removeJournalFiles 
Sun Dec 22 15:37:36.525 [signalProcessingThread] shutdown: removing fs lock... 
Sun Dec 22 15:37:36.525 dbexit: really exiting now 

話又說回來:

[email protected]:~# mongod 
mongod --help for help and startup options 
Sun Dec 22 15:37:44.081 [initandlisten] MongoDB starting : pid=18415 port=27017 dbpath=/data/db/ 64-bit host=cs12867 
Sun Dec 22 15:37:44.081 [initandlisten] db version v2.4.6 
Sun Dec 22 15:37:44.081 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673 
Sun Dec 22 15:37:44.081 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49 
Sun Dec 22 15:37:44.081 [initandlisten] allocator: tcmalloc 
Sun Dec 22 15:37:44.081 [initandlisten] options: {} 
Sun Dec 22 15:37:44.081 [initandlisten] exception in initAndListen: 10296 
********************************************************************* 
ERROR: dbpath (/data/db/) does not exist. 
Create this directory or give existing directory in --dbpath. 
See http://dochub.mongodb.org/core/startingandstoppingmongo 
********************************************************************* 
, terminating 
Sun Dec 22 15:37:44.081 dbexit: 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close listening sockets... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to flush diaglog... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close sockets... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: waiting for fs preallocator... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: lock for final commit... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: final commit... 
Sun Dec 22 15:37:44.081 [initandlisten] shutdown: closing all files... 
Sun Dec 22 15:37:44.081 [initandlisten] closeAllFiles() finished 
Sun Dec 22 15:37:44.081 dbexit: really exiting now 
+0

您正在使用的操作系統? –

+0

GNU/Linux Debian 6 –

+0

看看我的答案。 –

回答

15

mongodb的默認db路徑是/data/db/

所以,當你運行:

mongod 

MongoDB的檢查/數據/ DB /存在,並且如果用戶訪問它。在你的情況下,沒有這樣的目錄,因此錯誤。

但是,您可以使用mongod的--dbpath參數(或使用配置文件)覆蓋默認數據庫路徑。

mongod --dbpath /var/lib/mongodb/data/db 

在這種情況下,而不是檢查/數據/分貝/ MongoDB的檢查/ var/lib中/ mongodb的/數據/分貝。你的情況,你有指定的目錄,你有權訪問它,因此它運行。

而這樣做並不能啓動mongo shell。要啓動shell,首先如上所述啓動mongod並保持運行。然後在另一個終端執行

mongo 

這將啓動mongo shell。

+0

它不運行,但它仍然退出,如果你在框中向下滾動 – Sammaye

+1

@Sammaye:它看起來像mongod啓動成功,當他使用--dbpath選項。 – 4J41

+0

哦,確定它沒有,文本的最後一個塊有他運行兩個命令 – Sammaye

2

當我從創建數據/ db目錄將解決您的問題,這個問題看。

創建它,然後像這樣添加,如果你有C盤中的目錄路徑。

mongod --dbpath "c://data/db"

設置DBPATH後,你應該開始MongoDB的是服務。

sudo service mongodb start 
相關問題