2016-09-04 63 views
1

我設置的MongoDB在Ubuntu 16.04有:MongoDB是不是在Ubuntu 16.04開始

echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list 
sudo apt-get update 
sudo apt-get install -y mongodb-org 

但我得到這些錯誤,當我嘗試啓動服務:

**~$** systemctl start mongodb 
Failed to start mongodb.service: Unit mongodb.service is masked. 

**~$** systemctl start mongod 
Failed to start mongod.service: Unit mongod.service not found. 

**~$** sudo service mongod start 
Failed to start mongod.service: Unit mongod.service not found. 

**~$** mongod 
mongod --help for help and startup options 
2016-09-04T11:20:59.074+0200 [initandlisten] MongoDB starting : pid=30207 port=27017 dbpath=/data/db 64-bit host=zantes 
2016-09-04T11:20:59.074+0200 [initandlisten] db version v2.6.10 
2016-09-04T11:20:59.074+0200 [initandlisten] git version: nogitversion 
2016-09-04T11:20:59.074+0200 [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips 1 Mar 2016 
2016-09-04T11:20:59.074+0200 [initandlisten] build info: Linux lgw01-12 3.19.0-25-generiC#26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 BOOST_LIB_VERSION=1_58 
2016-09-04T11:20:59.074+0200 [initandlisten] allocator: tcmalloc 
2016-09-04T11:20:59.074+0200 [initandlisten] options: {} 
2016-09-04T11:20:59.074+0200 [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 
2016-09-04T11:20:59.074+0200 [initandlisten] dbexit: 
2016-09-04T11:20:59.074+0200 [initandlisten] shutdown: going to close listening sockets... 
2016-09-04T11:20:59.074+0200 [initandlisten] shutdown: going to flush diaglog... 
2016-09-04T11:20:59.074+0200 [initandlisten] shutdown: going to close sockets... 
2016-09-04T11:20:59.074+0200 [initandlisten] shutdown: waiting for fs preallocator... 
2016-09-04T11:20:59.074+0200 [initandlisten] shutdown: lock for final commit... 
2016-09-04T11:20:59.074+0200 [initandlisten] shutdown: final commit... 
2016-09-04T11:20:59.074+0200 [initandlisten] shutdown: closing all files... 
2016-09-04T11:20:59.074+0200 [initandlisten] closeAllFiles() finished 
2016-09-04T11:20:59.074+0200 [initandlisten] dbexit: really exiting now 

但是當我檢查狀態是積極的,請幫助我。我不知道我必須做什麼!

**~$** sudo systemctl status mongodb 
**●** mongodb.service - An object/document-oriented database 
    Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor prese 
    Active: active (running) since dom 2016-09-04 11:01:11 CEST; 20min ago 
    Docs: man:mongod(1) 
Main PID: 27544 (mongod) 
    CGroup: /system.slice/mongodb.service 
      └─27544 /usr/bin/mongod --config /etc/mongodb.conf 

set 04 11:01:11 zantes systemd[1]: Started An object/document-oriented databa 
lines 1-9/9 (END) 

我以前工作的C9,但它有這麼多的問題,是緩慢的,我需要的MongoDB爲我的項目工作 (對不起,我的壞簡體)

回答

1

某處錯誤消息,它說「 dbpath(/ data/db)不存在「。 「/ data/db」是mongodb存儲其數據文件的默認目錄。你必須手動創建它。看來這條道路不存在。

如果要更改此路徑,請將--dbpath參數傳遞給mongod或更改mongodb.conf文件中的dbpath參數值。