MongoDB server端的启动和添加到服务。

来源:互联网 发布:crf算法理解 编辑:程序博客网 时间:2024/06/16 09:22

https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.2.7-signed.msi将MongoDB服务器作为Windows服务运行请注意,你必须有管理权限才能运行下面的命令。执行以下命令将MongoDB服务器作为Windows服务运行:mongod.exe --bind_ip 127.0.0.1 --logpath "D:\mongodb_datas\log\mongodb.log" --logappend --dbpath "D:\mongodb_datas" --port 27017 --serviceName "MongoDB3.2" --serviceDisplayName "MongoDB3.2" --installmongod.exe --bind_ip 127.0.0.1 --logpath D:/mongodb_datas/log/mongodb.log --logappend --dbpath D:/mongodb_datas --port 27017 --directoryperdb --serviceName "MongoDB3.2" -install  mongod.exe --bind_ip 127.0.0.1 --logpath "D:\mongodb_datas\log\mongodb.log" --logappend --dbpath "D:\mongodb_datas" --port 27017 --directoryperdb --serviceName "MongoDB3.2" --serviceDisplayName "MongoDB3.2" --install默认端口:27017??在命令行下启动mongodb:# 注:在启动命令后添加 参数 --install  则是添加到服务了。①、直接携带参数的形式启动:# 最简单的形式,只是指定 dbpathmongod.exe --dbpath D:\mongodb datas<strong><span style="color:#ff0000;"># 如果启动的时候添加directoryperdb参数:# 好像没启动起来,要求安装补丁:Hotfix KB2731284</span></strong>mongod.exe --dbpath D:\mongodb_datas --directoryperdbmongod.exe --dbpath D:\mongodb_datas --directoryperdb true# 比较完整的参数:mongod.exe  --bind_ip 127.0.0.1 --port 27017 --dbpath D:\mongodb_datas --logpath=D:\mongodb_datas\log\mongodb.log --logappend②、通过加载配置文件加载配置信息的方式启动 mongodb:mongod --config D:\mongodb_datas\config\mongodb.cfg配置文件的内容如下:参照https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/systemLog:destination: filepath: D:\mongodb_datas\log\mongodb.logstorage:dbPath: D:\mongodb_datas查询帮助:mongod.exe -h命令行下添加 MongoDB 服务:需要以管理员的权限启动cmd才行#添加服务的时候,好像强制要求必须得有logpathmongod.exe --dbpath D:\mongodb_datas --logpath=D:\mongodb_datas\log\mongodb.log --installmongod.exe --config C:\mongodb\mongod.cfg --dbpath D:\Mongodb --install sc create mongodb binPath= "D:\Program Files\MongoDB\Server\3.2\bin\mongod.exe --service --bind_ip 127.0.0.1 --port 27017 --dbpath D:\mongodb_datas --logpath=D:\mongodb_datas\log\mongodb.log --logappend --directoryperdb"sc.exe create MongoDB binPath= "D:\Program Files\MongoDB\Server\3.2\bin\mongod.exe --service --config=\"D:\mongodb_datas\config\mongodb.cfg\"" DisplayName= "MongoDB" start= "auto"移除服务:mongod --removesc delete MongoDB:通过该方式删除的话,服务中的 mongod仍会存在,注册表中不存在了,再重启之后服务的mongodb才会消失。启动MongoDB:net start MongoDB停止MongoDB:net stop MongoDB


0 0
原创粉丝点击