net start mongodb发生系统错误2 系统找不到指定的文件
安装mongodb时, 将mongodb 作为系统服务启动 net start mongodb,报错发生系统错误2 系统找不到指定的文件 .
查找原因是因为,系统服务的可执行文件地址有误. 修改服务地址即可恢复!
总结一下如何将mongoDB安装为WinXP下系统服务。
使用的命令如下:
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
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
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
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