總結一下如何將mongoDB安裝為WinXP下系統服務。
使用的命令如下:
復制代碼 代碼如下:
Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>mongod -dbpath C:\mongo\MongoDB\mongo\data --logpath=C:\mongo\MongoDB\mongo\logs\mongodb.log --auth --install
all output going to: C:\mongo\MongoDB\mongo\logs\mongodb.log
但是無法連接:
復制代碼 代碼如下:
C:\Documents and Settings\Administrator>mongo
MongoDB shell version: 2.0.1
connecting to: test
Tue May 29 18:07:50 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:8
4
exception: connect failed
看了一下日志,還需要使用net start MongoDB命令來啟動服務,日志如下:
復制代碼 代碼如下:
Creating service MongoDB.
Service creation successful.
Service can be started from the command line via 'net start "MongoDB"'.
Tue May 29 18:06:43 dbexit:
Tue May 29 18:06:43 shutdown: going to close listening sockets...
Tue May 29 18:06:43 shutdown: going to flush diaglog...
Tue May 29 18:06:43 shutdown: going to close sockets...
Tue May 29 18:06:43 shutdown: waiting for fs preallocator...
Tue May 29 18:06:43 shutdown: closing all files...
Tue May 29 18:06:43 closeAllFiles() finished
Tue May 29 18:06:43 dbexit: really exiting now
按照提示,在CMD下運行 net start MongoDB
復制代碼 代碼如下:
net start "MongoDB"'
C:\Documents and Settings\Administrator>net start mongoDB
發生系統錯誤 2。
系統找不到指定的文件。
通過控制面板–》管理工具–》服務,查看了一下剛才安裝的服務:
不知為何mongod命令所在的路徑變成了C:\Documents and Settings\Administrator\,如下所示:
復制代碼 代碼如下:
"C:\Documents and Settings\Administrator\mongod" -dbpath C:\mongo\MongoDB\mongo\data --logpath=C:\mongo\MongoDB\mongo\logs\mongodb.log --auth --service
指定好mongod的路徑,重新安裝:
復制代碼 代碼如下:
C:\mongo\MongoDB\mongo\bin>C:\mongo\MongoDB\mongo\bin\mongod -dbpath C:\mongo\MongoDB\mongo\data --logpath=C:\mongo\MongoDB\mongo\logs\mongodb.log --auth --install
all output going to: C:\mongo\MongoDB\mongo\logs\mongodb.log
這次啟動成功了。