2016-02-05 145 views
1

我在Azure VPS上運行Ubuntu 15。我安裝了MongoDB並啓動並運行正常。於是,我停止了mongod服務,我改變了數據庫路徑和日誌路徑mongod.conf指向我一個附加的磁盤上創建的目錄:Mongo無法連接

# Where and how to store data. 
storage: 
    dbPath: /datadrive/lib/mongodb 
    journal: 
    enabled: true 
# engine: 
# mmapv1: 
# wiredTiger: 

# where to write logging data. 
systemLog: 
    destination: file 
    logAppend: true 
    path: /datadrive/log/mongodb/mongod.log 

我重新啓動整個VPS進行雙重確認的新變化生效。現在,當我鍵入mongo我收到以下錯誤:如果我扭轉我的變化,並使用原來的loglib位置

2016-02-05T14:49:41.004+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused 
2016-02-05T14:49:41.018+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : 
[email protected]/mongo/shell/mongo.js:224:14 
@(connect):1:6 

,它的工作原理。我能做些什麼來確保使用新地點?

編輯

保留舊日誌的位置和嘗試上述步驟後,我得到了在日誌中以下內容:

2016-02-05T15:19:47.049+0000 I CONTROL [main] ***** SERVER RESTARTED ***** 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] MongoDB starting : pid=1158 port=27017 dbpath=/datadrive/lib/mongodb 64-bit host=CLIENTPROJECTS 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] db version v3.2.1 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] git version: a14d55980c2cdc565d4704a7e3ad37e4e535c1b2 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2d 9 Jul 2015 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] allocator: tcmalloc 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] modules: none 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] build environment: 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten]  distmod: ubuntu1404 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten]  distarch: x86_64 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten]  target_arch: x86_64 
2016-02-05T15:19:47.146+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/datadrive/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } } 
2016-02-05T15:19:47.693+0000 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /datadrive/lib/mongodb/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating 
2016-02-05T15:19:47.693+0000 I CONTROL [initandlisten] dbexit: rc: 100 
+0

mongodb啓動時的任何日誌?看來運行mongod的帳戶在新目錄中沒有保留。 – Peter

+0

@Peter沒有日誌。它沒有使用新的日誌位置。有任何想法嗎? – Coop

+1

保持舊的日誌位置,看看出了什麼問題 – Peter

回答

1

首先,你可以檢查是否mongod的開始:sudo lsof -i | grep 27017和然後檢查日誌/datadrive/log/mongodb/mongod.log中的內容。

編輯:

停止的mongod的所有實例(ps aux | grep mongod應該什麼都不顯示的運行),刪除鎖定文件rm /datadrive/lib/mongodb/mongod.lock,並重新啓動服務。

EDIT2:從配置/datadrive/lib/mongodb//datadrive/log/mongodb/應該存在,屬於MongoDB的用戶

目錄。默認情況下它是mongodb:mongodb,在/etc/init.d/mongodb中定義爲DAEMONUSER

+0

在該位置沒有創建日誌,因爲整個問題是lib和log的新路徑。使用新路徑並不開心,所以它不會記錄到它。 – Coop

+0

我使用'sudo mkdir'創建了新的位置,以便它們擁有root用戶和組。他們都有755個權限。 – Coop

+0

我創建的新的lib和日誌是空的。舊的日誌和文件在 – Coop