MongoDB cannot start a workaround

Source: Internet
Author: User

http://dmyz.org/archives/423

When MongoDB suddenly fails to start, the first reaction is to remove Mongod.lock. This file is in the database directory of MongoDB, the default is/data/db. This is the most common problem, due to the fact that MongoDB does not end properly (such as being killed by kill-9 or other unexpected conditions that cause interruptions).

There are other things that can cause MongoDB to fail to start. This article discusses the inability to start , referring to: Using /etc/init.d/mongodb start or sudo service mongdb start, hint MongoDB start/ Running, but viewing status is still stop/waiting.

Service SERVERNAME status may be false positives, first confirm the actual state of MongoDB. The main is PS axu|grep mongod See if there are related processes, open links or directly with the browser to access 127.0.0.1:28017, do not see the information of MongoDB description does not start.

Then execute:

$ sudo mongod--repair--config/etc/mongodb.conf
$ sudo mongod--config/etc/mongodb.conf

The first command is the repair operation, the second command is to manually specify the MongoDB configuration file, run directly in the terminal, so that the output error is more intuitive, not to go through the log. If you can run Mongod, the configuration file and database are not a problem,/usr/bin/mongodb permissions are not enough, please refer to the Setcap method at the end of this article.

If not run, you can see the error message, in three cases: Configuration file error, data directory settings error,/usr/bin/mongod file error.

Configuration file error is obvious, parameter error will explicitly prompt error command line:unknown option xxx. The second command explicitly specifies which configuration file to use, and is also prone to troubleshooting. So in addition to the previous with MongoDB master-Slave modification configuration file was broken once, rarely encountered configuration file problems.

The second is the data directory, mainly the permissions problem, the possible error is:

Thu 10:03:30 [Initandlisten] warning couldn ' t write To/rename file/srv/mongodb/journal/prealloc.0
Thu 10:03:30 [Initandlisten] couldn ' t open/srv/mongodb/duoshuo.ns errno:1 operation not permitted
Thu 10:03:30 [Initandlisten] Error couldn ' t open file/srv/mongodb/duoshuo.ns terminating

The owner of the data catalog should be mongodb:mongodb.

$ sudo chown mongodb:mongodb MongoDB

The last case is a/usr/bin/mongod problem. Its error and directory does not have read and write permissions, but even if you set the MongoDB database directory to 777, there will be a problem. Because Mongod is the O_NOATIME flag to access the file system, MongoDB does not have this permission, with Setcap settings:

# Setcap Cap_fowner+ep/usr/bin/mongod

If this is not possible ... Back up the database and Apt-get purge unload the load.

MongoDB cannot start a workaround

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.