MongoDB注册为Windows服务时遇到的问题

MongoDB注册为Windows服务时遇到的问题

日志中报错(拒绝访问)

转载https://www.cnblogs.com/ningskyer/articles/6292891.html
和这篇文章基本一致
一:MongoDB安装完后,将其注册成windows服务。

方式有两种:

1.通过命令行参数
mongod --dbpath “D:\1\12\mongodb\data\db” --logpath “D:\1\12\mongodb\data\log\mongodb.log” --install --serviceName “MongoDB”

2.通过配置文件
mongod --install -f “D:\Program Files\MongoDB\mongo.conf”

mongo.conf内容如下:

dbpath = “D:\Program Files\MongoDB\Data\DB”
logpath = “D:\Program Files\MongoDB\Data\Log\mongodb.log”
logappend = true
directoryperdb = true
serviceName = “MongoDBService”
serviceDisplayName = “MongoDBService1”
port = 27017

命令执行后命令行没有任何输出直接结束了,但是启动服务时调用net start MongoService没有反应——注册服务失败。

查看日志文件mongodb.log,发现如下记录:

59:46.730+0800 I CONTROL [main] ***** SERVER RESTARTED *****
59:47.130+0800 I CONTROL [main] Trying to install Windows service ‘MongoDBService’
59:47.130+0800 I CONTROL [main] Error connecting to the Service Control Manager: 拒绝访问。 (5)
解决方法:

找到cmd.exe,右键以管理员身份运行,然后再执行上述注册服务的命令。

二:又报错误:
logPath requires an absolute file path with Windows services

dbPath requires an absolute file path with Windows services
解决方法:

将配置文件中引号去掉

三:安装成功:

再次执行注册服务的命令之后查看日志,发现如下记录,说明安装成功:

23:53.286+0800 I CONTROL [main] Trying to install Windows service ‘“MongoDBService”’
23:53.286+0800 I CONTROL [main] Service ‘“MongoDBService”’ (“MongoDBService1”) installed with command line ‘“D:\Program Files\MongoDB\Server\3.4\bin\mongod.exe” --config D:\program\MongoDB\mongo.conf --service’
23:53.286+0800 I CONTROL [main] Service can be started from the command line with ‘net start “MongoDBService”’

四:启动服务:
D:>net start MongoDBService
The MongoDBService1 service is starting…
The MongoDBService1 service was started successfully.

启动时服务器100错误

转载https://www.cnblogs.com/BGOnline/p/6813804.html
解决方法见此:
主要就是打开之前data存储文件夹–dbpath(D:\1\12\mongodb\data\db我的存储文件) 删除mongod.lock storage.bson这两个文件

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值