Mongodb 无法在 Ubuntu 15.04 中启动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33010719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mongodb not able to start in Ubuntu 15.04
提问by M.J
I have installed MongoDB 3.0.6 in Ubuntu 15.04 using the following commands.
我已经使用以下命令在 Ubuntu 15.04 中安装了 MongoDB 3.0.6。
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
In the end in the installation process I got this:
最后在安装过程中我得到了这个:
Job for mongod.service failed. See "systemctl status mongod.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mongod, action "start" failed.
dpkg: error processing package mongodb-org-server (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up mongodb-org-mongos (3.0.6) ...
Setting up mongodb-org-tools (3.0.6) ...
dpkg: dependency problems prevent configuration of mongodb-org:
mongodb-org depends on mongodb-org-server; however:
Package mongodb-org-server is not configured yet.
dpkg: error processing package mongodb-org (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for systemd (219-7ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
mongodb-org-server
mongodb-org
E: Sub-process /usr/bin/dpkg returned an error code (1)
After that when I start the server using the below command I get an error and the server is not started.
之后,当我使用以下命令启动服务器时,出现错误并且服务器未启动。
sudo service mongod start
And the error is
错误是
Job for mongod.service failed. See "systemctl status mongod.service" and "journalctl -xe" for details.
Now when I run:
现在当我运行时:
sudo systemctl status mongod.service
I get the following:
我得到以下信息:
mongod.service - LSB: An object/document-oriented database
Loaded: loaded (/etc/init.d/mongod)
Active: failed (Result: exit-code) since Thu 2015-10-08 13:46:08 IST; 22s ago
Docs: man:systemd-sysv-generator(8)
Process: 6604 ExecStart=/etc/init.d/mongod start (code=exited, status=1/FAILURE)
Oct 08 13:46:07 gariya-GA-A55M systemd[1]: Starting LSB: An object/document-oriented database...
Oct 08 13:46:07 gariya-GA-A55M mongod[6604]: * Starting database mongod
Oct 08 13:46:08 gariya-GA-A55M mongod[6604]: ...fail!
Oct 08 13:46:08 gariya-GA-A55M systemd[1]: mongod.service: control process exited, code=exited status=1
Oct 08 13:46:08 gariya-GA-A55M systemd[1]: Failed to start LSB: An object/document-oriented database.
Oct 08 13:46:08 gariya-GA-A55M systemd[1]: Unit mongod.service entered failed state.
Oct 08 13:46:08 gariya-GA-A55M systemd[1]: mongod.service failed.
Someone please help, I am new to Ubuntu and MongoDB and I am not getting what is the problem.
有人请帮忙,我是 Ubuntu 和 MongoDB 的新手,我不明白是什么问题。
回答by pwojnowski
There is a log file: /var/log/mongodb/mongod.log
有一个日志文件:/var/log/mongodb/mongod.log
In the log I've found the following:
在日志中,我发现了以下内容:
Failed to unlink socket file /tmp/mongodb-27017.sock errno: Operation not permitted
Most probably this was from previous MongoDB version. I deleted the file (rm -rf /tmp/mongodb-27017.sock) and finished the installation:
这很可能来自以前的 MongoDB 版本。我删除了文件(rm -rf /tmp/mongodb-27017.sock)并完成了安装:
apt-get install mongodb-org
Now it works. :-)
现在它起作用了。:-)
回答by Prasad G K
Recently i ended up with same issue and i tried all the possible solutions explained up here. But it didn't worked out for me. I was getting the below error.
最近我遇到了同样的问题,我尝试了这里解释的所有可能的解决方案。但这对我没有用。我收到以下错误。
# sudo service mongod restart
Restarting mongod (via systemctl): Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details. [FAILED]
Eventually i figured out the solution which worked for me.
I went to /run/mongodb
folder and deleted the file called mongod.pid
. Then tried to restart the mongo using # sudo service mongod restart
and it's worked!
最终我想出了对我有用的解决方案。我去了/run/mongodb
文件夹并删除了名为mongod.pid
. 然后尝试使用重新启动mongo# sudo service mongod restart
并且它起作用了!
回答by aarkerio
My log said:
我的日志说:
[initandlisten] Found an invalid index { v: 2, key: { version: 1 }, name: "incompatible_with_version_32", ns: "admin.system.version"
so:
所以:
$cd /var/lib
$sudo rm -rf ./mongodb
$sudo mkdir mongodb
$sudo chown -R mongodb.mongodb mongodb/
$sudo service mongod restart
and then all worked fine.
然后一切正常。
回答by Лосевка FM
sudo nano /etc/systemd/system/mongodb.service
须藤纳米 /etc/systemd/system/mongodb.service
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
sudo systemctl start mongodb
须藤 systemctl 启动 mongodb
sudo systemctl status mongodb
须藤 systemctl 状态 mongodb
sudo systemctl enable mongodb
须藤 systemctl 启用 mongodb
Is job!
是工作!
回答by Sarah De-Paz
I removed the mongodb lock file-
我删除了mongodb锁文件-
sudo /data/db/mongod.lock
须藤/数据/数据库/mongod.lock
Then restarted the mongodb
然后重启mongodb
sudo service mongod restart
须藤服务 mongod 重启
This solved the issue.
这解决了这个问题。
回答by TMichel
- Make sure that the
/data/db
directory exists Make sure your user have write privileges in that directory:
$ sudo chown
id -u
/data/dbExecute
mongod
- 确保
/data/db
目录存在 确保您的用户在该目录中具有写入权限:
$ sudo chown
id -u
/data/db执行
mongod
If you still have problems and if the file /data/db/mongod.lock
exists, remove it and execute mongod --repair
.
如果仍然有问题并且文件/data/db/mongod.lock
存在,请将其删除并执行mongod --repair
.
回答by naXa
The first thing you should check is a mongodb log file located at /var/log/mongodb/mongod.log
您应该检查的第一件事是位于 /var/log/mongodb/mongod.log 的 mongodb 日志文件
Look for the line with status E
containing words like 'failed', 'fatal', etc.
查找状态E
包含“失败”、“致命”等词的行。
回答by Satpal Tanan
I was having the same issue, after searching I got the answer that, when I executed
我遇到了同样的问题,搜索后我得到了答案,当我执行
sudo service mongod restart
I changed the permissions from user mongodb to root of the database folder, so the service was not able to read the data. So to solve I just reverted the permissions back to the user mongodb
我将用户 mongodb 的权限更改为数据库文件夹的根目录,因此该服务无法读取数据。所以为了解决我只是将权限恢复给用户 mongodb
sudo chown -R mongodb:mongodb /path-to-db-folder
sudo service mongod restart