CenterOS7下設定mongoDB自啟動
阿新 • • 發佈:2018-12-14
一 、在/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 /mongodb/bin/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/mongodb/bin/mongod --shutdown --config /mongodb/bin/mongodb.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.targe
二、設定許可權
chmod 754 mongodb.service
三、啟動關閉服務,設定開機啟動
#啟動服務
systemctl start mongodb.service
#關閉服務
systemctl stop mongodb.service
#開機啟動
systemctl enable mongodb.service