Note:本教程基于Centos 7
解压MongoDB程序
新建数据和日志文件夹
设置环境变量
vi ~/.bash_profile
source ~/.bash_profile
编辑MongoDB启动脚本
mongod.service
[Unit]
Description=mongodb
[Unit]
Description=mongodb
[Unit]
Description=mongodb
[Service]
Type=forking
PIDFile=/home/Xesygao/software/MongoDB/data/db/mongod.lock
ExecStart=/home/Xesygao/software/MongoDB/mongodb/bin/mongod --dbpath /home/Xesygao/software/MongoDB/data/db --logpath /home/Xesygao/software/MongoDB/logs/mongodb.logs --logappend --fork
ExecReload=/bin/kill -s HUP MAINPID
ExecStop=/bin/kill -s QUITMAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
启动MongoDB
systemctl start mongod
验证是否启动成功
mongo
Comments | Nothing