您的位置:首页 > 数据库 > Mongodb

Mongodb~Linux环境下的部署~服务的部署与自动化

2017-07-10 11:57 701 查看
<mongodb在linux上的部署>

事实上redis安装程序挺好,直接帮我们生成了服务,直接可以使用systemctl去启动它,而mongodb在这方面没有那么智能,需要我们去编写自己的服务脚本了,然后把它加到开机自启动里面就可以了,主要的过程分为以下几个步骤:

mongodb我安装在了/root/tools目录下

一 配置文件,ANSI,记事本编写,UTF8可能有问题

dbpath=/root/tools/mongodb-linux-x86_64-amazon-3.4.2/db
logpath=/root/tools/mongodb-linux-x86_64-amazon-3.4.2/log/mongo.log
logappend=true
port=27017
fork=true
nohttpinterface=true
auth=false


二 服务文件,文件位于:/usr/lib/systemd/system

[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/root/tools/mongodb-linux-x86_64-amazon-3.4.2/bin/mongod --config /root/tools/mongodb-linux-x86_64-amazon-3.4.2/bin/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/root/tools/mongodb-linux-x86_64-amazon-3.4.2/bin/mongod --shutdown --config /root/tools/mongodb-linux-x86_64-amazon-3.4.2/bin/mongodb.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target


三 服务命令

#文件权限
chmod 754 mongodb.service
#启动服务
systemctl start mongodb.service
#关闭服务
systemctl stop mongodb.service
#开机启动
systemctl enable mongodb.service


这你几步之后,我们的mongodb服务就做好了!

感谢各位阅读!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: