MongoDB 3.4 安裝以 Windows 服務方式運行

來源:互聯網
上載者:User

標籤:log   --   https   pat   另一個   manual   system   code   沒有許可權   

1.首先從https://www.mongodb.com/download-center#community 下載社區版,企業版也是類似。

2.雙擊運行安裝,可自訂安裝路徑,這裡採用預設路徑(C:\Program Files\MongoDB\Server\3.4)

一路下一步直至安裝完畢。

3.建立資料存放目錄(這裡我放在D:\MongoDB\data)。

D:\MongoDB\data建立db目錄和log目錄,分別用來存放資料庫檔案和記錄檔。

4.建立設定檔mongod.cfg存放在D:\MongoDB目錄下。

systemLog:    destination: file    path: D:\MongoDB\data\log\mongod.logstorage:    dbPath: D:\MongoDB\data\db

更多配置請參見官網文檔:https://docs.mongodb.com

5.以管理員身份運行命令提示字元(否則會沒有許可權建立和啟用Windows服務):

sc.exe create MongoDB binPath="C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe --service --config=\"D:\MongoDB\mongod.cfg\"" DisplayName="MongoDB" start="auto"
net start MongoDB

PS:刪除MongoDB Windows服務的命令是:sc delete MongoDB

至此,MongoDB for Windows Service 已安裝完畢。

 

在使用過程中,可能會碰到以下錯誤:

1.無法建立另一個系統號誌。

只需要進入MongoDB的資料庫存放目錄(例如D:\MongoDB\data\db),將此檔案夾下的mongod.lock刪除,重新啟動MongoDB服務即可。

 

本文參考自:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#configure-a-windows-service-for-mongodb-community-edition

http://www.cnblogs.com/wangqiideal/p/6110073.html

MongoDB 3.4 安裝以 Windows 服務方式運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.