Cent OS 7上需要把mongoDB添加到systemd,否则会出现上面的错误
将mongoDB添加到systemd
# vim /usr/lib/systemd/system/mongod.service
[Unit]
Description=mongodb database[Service]
User=mongod
Group=mongod
Environment="OPTIONS=--quiet -f /etc/mongod.conf"
ExecStart=/usr/bin/mongod $OPTIONS run
PIDFile=/var/run/mongodb/mongod.pid[Install]
WantedBy=multi-user.target
建立链接ln -s /usr/lib/systemd/system/mongod.service /etc/systemd/system/multi-user.target.wants/
重新加载systemctlsystemctl daemon-reload