如何设置MongoDB,使其可以作为Windows服务运行?
当前回答
对于2.4.3版本(发布日期的当前版本),创建一个配置文件,然后执行以下命令:
C:\MongoDB\bin\mongo .exe——config C:\MongoDB\mongo .cfg——service
其他回答
我发现你应该用install标志将:dbpath, config和logfile传递给mongod
例子:
mongod --dbpath=c:\data\db --config=c:\data\db\config.cfg --logpath=c:\data\db\log.txt --install
注意:我的路径变量中有mongod path。
你可以通过以下方式控制服务:
net start mongodb
net stop mongodb
这对我来说很管用:
sc.exe create MongoDB binPath= "d:\MongoDB\bin\mongod.exe --service --config=d:\MongoDB\bin\mongod.config" displayname= "MongoDB 2.6 Standard" start= "auto"
逃脱binPath是失败的我在Mongo文档中描述
失败:
sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB 2.6 Standard\mongod.cfg\"" DisplayName= "MongoDB 2.6 Standard" start= "auto"
目前(直到2.4.4版本),如果任何路径(dbpath/logpath/config)包含空格,那么服务将不会启动,并显示错误:“服务没有响应控制功能”。
mongod --config "C:\Program Files\MongoDB\Server\3.6\mongod_primary.cfg" --install --serviceName "MongoDB_Primary" --serviceDisplayName "MongoDB Primary"
check windows services if you have service for mongo remove it by run bellow command mongod --remove create mongo.cfg file with bellow content systemLog: destination: file path: c:\data\log\mongod.log storage: dbPath: c:\data\db path: where you want to store log datas dbPath: your database directory then run bellow command sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB\Server\3.2\mongod.cfg\"" DisplayName= "MongoDB" start= "auto" binPath : mongodb installation directory config: .cfg file address DisplayName:Your Service Name start service net start MongoDB
现在一切都办好了。享受,
推荐文章
- 在MongoDB中查找重复的记录
- 为什么MongoDB Java驱动在条件中使用随机数生成器?
- 在猫鼬,我如何排序的日期?(node . js)
- 将映像存储在MongoDB数据库中
- 重复Mongo ObjectId的可能性在两个不同的集合中生成?
- Redis比mongoDB快多少?
- 亚马逊SimpleDB vs亚马逊DynamoDB
- 无法连接到服务器127.0.0.1:27017
- 如何创建数据库的MongoDB转储?
- 如何将MongoDB作为Windows服务运行?
- 如何监听MongoDB集合的变化?
- 什么时候不使用Cassandra?
- 如何在猫鼬排序?
- BASE术语解释
- .msi和setup.exe文件之间的具体区别是什么?