MongoDB在Linux系统上变成开机自启

上官网下载下载相对应平台和架构的压缩包

service化管理
sudo nano /etc/systemd/system/mongoDB.service
写入

[Unit]
# 服务名称,可自定义
Description = mongodb Service
After = network.target syslog.target
Wants = network.target

[Service]
Type = simple
# 启动frps的命令,需修改为您的mongod的安装路径,例如/usr/bin/mongod --config /etc/mongod.conf
ExecStart = /usr/bin/mongod --config /etc/mongod.conf

[Install]
WantedBy = multi-user.target


在浏览器中打开http://localhost:27017进行测试

# 启动mongoDB
systemctl start mongoDB
# 停止mongoDB
systemctl stop mongoDB
# 重启mongoDB
systemctl restart mongoDB
# 查看mongoDB状态
systemctl status mongoDB
配置 mongoDB开机自启。

systemctl enable mongoDB

猜你喜欢

转载自blog.csdn.net/u013833472/article/details/129958405