简体   繁体   中英

Mongo database cannot start

Hello everyone all help is much appreciated. Using MongoDB for the first time, I usually use postgresql. Cannot get any database action, including generating models. Continually get this error:

Mongo::ConnectionFailure: Failed to connect to a master node at localhost:27017

The internet says to try these, none of which work:

1-

sudo rm /var/lib/mongodb/mongod.lock
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
sudo start mongodb
sudo status mongodb

This returns the error that

rm: /var/lib/mongodb/mongod.lock: No such file or directory

2- This is in a file I put in the initialize folder

require 'rubygems'
require 'mongo'

db = Mongo::Connection.new.db("mydb")
db = Mongo::Connection.new("localhost").db("mydb")
db = Mongo::Connection.new("localhost", 27017).db("mydb")

The problem seems to stem from a path, which I have no idea how it works or how to alter it, so if the advice is to alter paths and folders etc. please be very specific. Thank you guys so much.

The mongo daemon has not successfully started.

Usually you do sudo mongod

Make sure you can connect to the database by typing mongo on the command line which should connect you to the daemon running on 27017.

Then try running your ruby code again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM