mongodb4 配置(centos7)

part 1:

etc/systemd/system/mongo.service

[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.service

part 2:

mongo/mongo-linux/bin/mongo.conf

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 貌似被取消了.

part 3:

#启动服务

systemctl start mongodb.service

#关闭服务

systemctl stop mongodb.service

#开机启动

systemctl enable mongodb.service

猜你喜欢

转载自www.cnblogs.com/maomingchao/p/11737515.html