1、进入cd /lib/systemd/system目录下

2、创建编辑  vi mongodb.service

3、把内容粘贴到mongodb.service中,保存退出

[Unit]

Description=mongodb
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/usr/local/mongodb/bin/mongod --shutdown --config /usr/local/mongodb/bin/mongodb.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

4、执行此命令 systemctl start mongodb.service
     如果报错执行   systemctl daemon-reload

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/haha66/p/13409335.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!