当我尝试运行“sudo service mongo start”时,输出是“无法启动 mongod.service:未找到单元 mongod.service。”
mongo 的输出是:
x2@jj2:~$ mongo
MongoDB shell version: 3.0.15
connecting to: test
2017-07-24T12:59:56.386+0530 W NETWORK Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2017-07-24T12:59:56.388+0530 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
状态为:-
x2@jj2:~$ sudo service mongodb status
● mongodb.service - High-performance, schema-free document-oriented database
Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset:
Active: failed (Result: exit-code) since Mon 2017-07-24 13:06:05 IST; 9min ag
Process: 29210 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (co
Main PID: 29210 (code=exited, status=1/FAILURE)
Jul 24 13:06:05 x2 systemd[1]: Started High-performance, schema-free docu
Jul 24 13:06:05 x2 systemd[1]: mongodb.service: Main process exited, code
Jul 24 13:06:05 x2 systemd[1]: mongodb.service: Unit entered failed state
Jul 24 13:06:05 x2 systemd[1]: mongodb.service: Failed with result 'exit-
答案1
你有:
Active: failed (Result: exit-code) since Mon 2017-07-24 13:06:05 IST; 9min ag
失败的意味着不运行因此你得到:
Failed to connect to 127.0.0.1:27017...
尝试运行:
sudo service mongodb restart