`
cooliufang
  • 浏览: 127656 次
社区版块
存档分类
最新评论

【MongoDB】MongoDB as Win7 service

阅读更多
Every time, we use mongoDB, must to manual input:

C:\users\XXX>cd /d d:\MongoDB\bin
d:\MongoDB\bin>mongod -dbpath D:\MongoDB\data

So, we can install it as Windows service.

Success:
Right click the command prompt, and open it with "Run as Administrator".

C:\Windows\system32>cd /d d:\MongoDB\bin
d:\MongoDB\bin>mongod -dbpath D:\MongoDB\data --logpath D:\MongoDB\logs\mongodb.log --logappend --directoryperdb --serviceName MongoDB --install
all output going to: D:\MongoDB\logs\mongodb.log


show mongodb.log
引用
Wed Dec 05 18:18:38 Trying to install Windows service 'MongoDB'
Wed Dec 05 18:18:38 Service 'MongoDB' (Mongo DB) installed with command line '"d:\MongoDB\bin\mongod.exe" -dbpath "D:\MongoDB\data" --logpath "D:\MongoDB\logs\mongodb.log" --logappend --directoryperdb --service '
Wed Dec 05 18:18:38 Service can be started from the command line with 'net start MongoDB'


start MongoDB:
d:\MongoDB\bin>net start MongoDB
The Mongo DB service is starting.
The Mongo DB service was started successfully.


stop MongoDB:
d:\MongoDB\bin>net stop MongoDB
System error 109 has occurred.
The pipe has been ended.

---> I dont know this question, but in the log file, the service was stopped.

delete MongoDB:
C:\Windows\System32>sc delete MongoDB
[SC] DeleteService SUCCESS

or run regedit, find HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet->Services->MongoDB, then delete it.

Attention:
1. --dbpath: data directory
   --directoryperdb: Each DB will create a new directory.
2. --logpath: log file directory
here,log file must be XXX.log, if it isn't existed, it will be created automatically.
   --logappend: XXX.log output in additional way.
3. --serviceName: Windows service name, here pay attention to the letter "N".
4. all the above commands must run as administrator.

Question in the process:
1.
d:\MongoDB\bin>mongod -dbpath D:\MongoDB\data --install
Wed Dec 05 18:07:37 --install has to be used with --logpath

------> This because we need to install --logpath

2. If we don't open the command prompt as administrator, it maybe occurrce the following error:
 Error connecting to the service Control Manager: Access is denied. (5)

or, we start MongoDB, also occurrce the error:
 System error 5 has occurred. 
Access is denied.

------> So must "Run as administrator".
  • 大小: 23.1 KB
  • 大小: 18.5 KB
  • 大小: 18.6 KB
  • 大小: 25.9 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics