linux mongodb开机启动(服务的方式)
设置mongodb.service启动服务
cd /lib/systemd/system
vi mongodb.service
[Unit] Description=mongodb After=network.target remote-fs.target nss-lookup.target [Service] Type=forking RuntimeDirectory=mongodb RuntimeDirectoryMode=0751 PIDFile=/var/run/mongodb/mongod.pid ExecStart=/usr/mongodb/bin/mongod --config /usr/mongodb/mongodb.conf ExecStop=/usr/mongodb/bin/mongod --shutdown --config /usr/mongodb/mongodb.conf PrivateTmp=false [Install] WantedBy=multi-user.target
mongodb.service服务
设置mongodb.service权限
chmod 754 mongodb.service
系统mongodb.service操作命令
#启动服务
systemctl start mongodb.service
#关闭服务
systemctl stop mongodb.service
#开机启动
systemctl enable mongodb.service
mongodb.service启动测试
mongodb服务启动测试

更多精彩