linux ubuntu mongodb 开机自启

ubuntu 版本 18.04

在另一篇中已经把mongodb的一些配置说明了,这里只介绍 nbuntu 的开机自启 sh文件

centos基本一次性就配置好了,但是ubuntu 配置试验了好长时间(主要是自己水平低),写这个作为以后的参考。

在 /ect/systemd/system/  创建 mymongodb.service  如下:

#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/mongodb/bin/start_mongodb.sh
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
[Install]  
WantedBy=multi-user.target  

sh文件添加权限

sudo chmod +x

更新配置

sudo systemctl daemon-reload              service文件改动后要重新转载一下
sudo systemctl enable my.service          这句是为了设置开机启动

立刻使用这个脚本

sudo systemctl start my.service           启动服务

 

 

参考:https://blog.csdn.net/qq570437459/article/details/87094870

参考:https://www.yuanmas.com/info/9ezZkJ2Ba6.html

参考: https://blog.csdn.net/dahuzix/article/details/80785691

参考:http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值