简体   繁体   English

Mongo数据库无法启动

[英]Mongo database cannot start

Hello everyone all help is much appreciated. 大家好,非常感谢。 Using MongoDB for the first time, I usually use postgresql. 第一次使用MongoDB,我通常使用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 Mongo :: ConnectionFailure:无法连接到本地主机上的主节点:27017

The internet says to try these, none of which work: 互联网说要尝试这些方法,但都不起作用:

1- 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 rm:/var/lib/mongodb/mongod.lock:没有这样的文件或目录

2- This is in a file I put in the initialize folder 2-这是我放在初始化文件夹中的文件中

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. mongo守护程序未成功启动。

Usually you do sudo mongod 通常你会做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. 确保可以通过在命令行上键入mongo来连接到数据库,该命令行应将您连接到运行在27017上的守护程序。

Then try running your ruby code again. 然后尝试再次运行红宝石代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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