part 1:linux
etc/systemd/system/mongo.servicemongodb
[Unit] Description=mongodb After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/mongo/mongodb-linux/bin/mongod --config /mongo/mongodb-linux/bin/mongo.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/mongo/mongodb-linux/bin/mongod --shutdown --config /mongo/mongodb-linux/bin/mongo.conf PrivateTmp=true [Install] WantedBy=multi-user.target
chmod 754 mongodb.servicebash
part 2:app
mongo/mongo-linux/bin/mongo.confspa
port=27017 bind_ip=0.0.0.0 dbpath=/mongo/mongodb-linux/db logpath=/mongo/mongodb-linux/log/mongo.log logappend=true auth=false fork=true
注意:mongo4的版本里面 nohttpinterface 貌似被取消了.code
part 3:blog
#啓動服務ip
systemctl start mongodb.servicerem
#關閉服務get
systemctl stop mongodb.service
#開機啓動
systemctl enable mongodb.service