2012-04-15 107 views
21

我已經下載了最新版本的mongodb,並將該文件移動並重命名爲mongodb,目錄爲usr/local/mongodb。當我嘗試運行的mongod我得到以下錯誤Mongodb安裝無法運行mongod

`./bin/mongod --help` for help and startup options 
Sun Apr 15 18:08:25 [initandlisten] MongoDB starting : pid=8801 port=27017 dbpath=/data/db/ 64-bit host=Hanss-MacBook-Air.local 
Sun Apr 15 18:08:25 [initandlisten] db version v2.0.4, pdfile version 4.5 
Sun Apr 15 18:08:25 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf 
Sun Apr 15 18:08:25 [initandlisten] build info: Darwin erh2.10gen.cc 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40 
Sun Apr 15 18:08:25 [initandlisten] options: {} 
Sun Apr 15 18:08:25 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating 
Sun Apr 15 18:08:25 dbexit: 
Sun Apr 15 18:08:25 [initandlisten] shutdown: going to close listening sockets... 
Sun Apr 15 18:08:25 [initandlisten] shutdown: going to flush diaglog... 
Sun Apr 15 18:08:25 [initandlisten] shutdown: going to close sockets... 
Sun Apr 15 18:08:25 [initandlisten] shutdown: waiting for fs preallocator... 
Sun Apr 15 18:08:25 [initandlisten] shutdown: lock for final commit... 
Sun Apr 15 18:08:25 [initandlisten] shutdown: final commit... 
Sun Apr 15 18:08:25 [initandlisten] shutdown: closing all files... 
Sun Apr 15 18:08:25 [initandlisten] closeAllFiles() finished 
Sun Apr 15 18:08:25 [initandlisten] shutdown: removing fs lock... 
Sun Apr 15 18:08:25 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor 
Sun Apr 15 18:08:25 dbexit: really exiting now 
+0

那麼,有沒有在數據目錄中的'mongod.lock'文件? – 2012-04-15 22:14:12

+2

有沒有,但我得到了mongod後使用sudo chown -R/data/db – 2012-04-15 22:32:31

回答

77

sudo chown -R <your-username> /data/db

哪個用戶運行的mongod?你是否使用常規登錄來運行它?

+1

我得到了mongo使用sudo chown -R/data/db來運行。想知道如果我能得到另一個問題的幫助。我嘗試使用mongo >> rails服務器運行我的rails項目,並且出現此錯誤: – 2012-04-15 22:30:17

+0

退出 /Library/Ruby/Gems/1.8/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in 'load':/Users/hansarijanto/Desktop/Impact/ribbot/config/initializers/session_store.rb:4:語法錯誤,意外':',期待$ end(SyntaxError) ... sion_store:cookie_store,key:' _ribbot_session',:domain => ... – 2012-04-15 22:30:32

+1

爲此創建另一個stackoverflow問題。我不是一個鐵桿球員。 – 2012-04-15 22:36:54

1

systemctl踢,因爲在init腳本的mongod的源文件最喜歡的人:

. /etc/rc.d/init.d/functions 

與chkconfig的塊註釋被用來定義配置和PID文件:

# config: /etc/my-mongod.conf 
# pidfile: /var/run/mongo/mongo.pid 

但是,pifile的路徑應該與配置的dbpath中的任何路徑匹配。 所以這/etc/my-mongod.conf

dbpath = /home/mongodb/2.0.5/data 

匹配與/etc/init.d/mongod此評論

# pidfile: /home/mongodb/2.0.5/data/mongod.lock 
+0

不清楚我們應該做什麼,除非這個解釋很有用 – c24b 2017-03-29 11:03:21

0

得到了同樣的錯誤,在Windows中以管理員權限運行解決了這個問題。

+0

不建議使用管理員權限運行:問題解決了這個特定的陳述 – c24b 2017-03-29 10:50:47

4

與「Joe Frambach's」相同,但有點友好,可以馬上剪下和粘貼。

sudo chown -R $(whoami) /data/db 
0

以下命令爲我工作:

sudo chown -R `id -u` /data/db