MongoDB安裝教程
mongodb的安裝比較簡(jiǎn)單,這里不作介紹,不動(dòng)安裝的朋友可以查看菜鳥(niǎo)教程,這里主要介紹如何設(shè)置mongodb開(kāi)機(jī)啟動(dòng)
Linux 平臺(tái)安裝 MongoDB | 菜鳥(niǎo)教程
設(shè)置mongodb開(kāi)機(jī)自動(dòng)啟動(dòng)服務(wù)
cd /lib/systemd/system 切換到/lib/systemd/system目錄下
執(zhí)行vi mongodb.service新建mongodb.service
[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/usr/local/mongodb/bin/mongod --shutdown --config /usr/local/mongodb/mongodb.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
mongodb.service服務(wù)
設(shè)置mongodb.service權(quán)限
chmod 754 mongodb.service
系統(tǒng)mongodb.service操作命令
啟動(dòng)服務(wù)
systemctl start mongodb.service
關(guān)閉服務(wù)
systemctl stop mongodb.service
開(kāi)機(jī)啟動(dòng)
systemctl enable mongodb.service