开机自启mongodb

如何将mongodb数据库设置开机自启

使用工具连接数据库在/lib/systemd/system/

下新建文件mongodb.service

[Unit]

Description=mongodb

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

[Service]

Type=forking

ExecStart=你的路径/mongodb/bin/mongod --config

/usr/context/mongodb/mongodb-3.2.10/bin/mongodb.conf

ExecReload=/bin/kill -s HUP $MAINPID

ExecStop=你的路径/mongodb/bin/mongod --shutdown --config

/usr/context/mongodb/mongodb-3.2.10/bin/mongodb.conf

PrivateTmp=true

[Install]

WantedBy=multi-user.target

保存文件,设置权限

chmod 754 mongodb.service

// 介绍一下chmod

7 = 4 + 2 + 1 读写运行权限

5 = 4 + 1 读和运行权限

4 = 4 只读权限

启动关闭服务,设置开机启动

#启动服务

systemctl start mongodb.service

#关闭服务

systemctl stop mongodb.service

#开机启动

systemctl enable mongodb.service

猜你喜欢

转载自blog.csdn.net/my_atlassian_yhl/article/details/84105226
今日推荐