如何设置MongoDB,使其可以作为Windows服务运行?
当前回答
MongoDB 3.4 [Windows]
Create dir C:/mongodb/data Create a file in C:/mongodb/mongodb.config using this configuration: storage: engine: wiredTiger dbPath: "C:/mongodb/data" directoryPerDB: true journal: enabled: true systemLog: destination: file path: "C:/mongodb/data/mongod.log" logAppend: true timeStampFormat: iso8601-utc net: bindIp: 127.0.0.1 port: 27017 wireObjectCheck : false To install MongoDb as a service, run this command in powershell with admin power mongod --config="C:\mongodb\mongodb.config" --install --service Open Services.msc and look for MongoDb, then start it
其他回答
不仅——安装,
还需要——dbpath和——logpath
重启操作系统后,你需要删除“mongod”。手动锁”
MongoDB 3.4 [Windows]
Create dir C:/mongodb/data Create a file in C:/mongodb/mongodb.config using this configuration: storage: engine: wiredTiger dbPath: "C:/mongodb/data" directoryPerDB: true journal: enabled: true systemLog: destination: file path: "C:/mongodb/data/mongod.log" logAppend: true timeStampFormat: iso8601-utc net: bindIp: 127.0.0.1 port: 27017 wireObjectCheck : false To install MongoDb as a service, run this command in powershell with admin power mongod --config="C:\mongodb\mongodb.config" --install --service Open Services.msc and look for MongoDb, then start it
以下步骤适用于Windows操作系统。
在下面的管理cmd中运行
mongod --remove
这将删除现有的MongoDB服务(如果有的话)。
mongod --dbpath "C:\data\db" --logpath "C:\Program Files\MongoDB\Server\3.4\bin\mongod.log" --install --serviceName "MongoDB"
确认C:\data\db文件夹存在
使用以下工具开放服务:
services.msc
Find MongoDB ->右键单击->开始
考虑使用
mongod --install --rest --master
经过几个小时的努力,我终于做到了。
确保:
您将<MONGODB_PATH>\bin目录添加到系统变量PATH中 以管理员身份运行命令提示符
步骤:
第一步:执行以下命令:
D:\mongodb\bin>mongod --remove
第二步:以管理员身份打开命令提示符后执行该命令:
D:\mongodb\bin>mongod --dbpath=D:\mongodb --logpath=D:\mongodb\log.txt --install
注意:你也可以在上面的命令后面附加——serviceName MongoDB。
这是所有!
After that right there in the command prompt execute:
services.msc
// OR
net start MongoDB
寻找MongoDB service并单击start。
注意:确保以管理员身份运行命令提示符。
如果你不这样做,你的日志文件(在上面的例子中是D:\mongodb\log.txt)将包含这样的行:
2016-11-11T15:24:54.618-0800 I CONTROL [main] Trying to install Windows service 'MongoDB'
2016-11-11T15:24:54.618-0800 I CONTROL [main] Error connecting to the Service Control Manager: Access is denied. (5)
如果你试图从非管理控制台启动服务(即net start MongoDB或start - service MongoDB在PowerShell中),你会得到这样的响应:
System error 5 has occurred.
Access is denied.
或:
Start-Service : Service 'MongoDB (MongoDB)' cannot be started due to the following error: Cannot open MongoDB service
on computer '.'.
At line:1 char:1
+ Start-Service MongoDB
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service],
ServiceCommandException
+ FullyQualifiedErrorId : CouldNotStartService,Microsoft.PowerShell.Commands.StartServiceComman
推荐文章
- 在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文件之间的具体区别是什么?