0

我的 ruby​​ 应用程序运行良好,直到本周早些时候,系统崩溃了,现在我在页面上收到一条错误消息......

错误消息: 无法连接到 localhost:27017 的主节点(Mongo::ConnectionFailure)

异常类: PhusionPassenger::UnknownError

应用程序根目录: /home/deploy/www/gm-git

系统是这样设置的...

• Ruby on Rails 3.0.8 • Mongoid 2.0.2 • Redis & Resque 用于后台处理

我尝试了以下启动顺序,但没有成功...

/opt/redis/redis-server
/opt/mongodb/bin/mongod --force --logpath /opt/mongodb/bin
rake environment rescue:workers
touch /home/proyectos/gm/test_git/goldenmile

我已经更新了很多次,例如

/opt/redis/redis-server
/opt/mongodb/bin/mongod --fork --logpath /opt/mongodb/bin
/opt/mongodb/bin/mongod --repair
rake environment rescue:workers
touch /home/proyectos/gm/test_git/goldenmile

但是我在终端中收到错误消息,例如

/opt/mongodb/bin/mongod --start
ERROR: unknown option start

/opt/mongodb/bin/mongod --status
ERROR: unknown option status

/opt/mongodb/bin/mongod start
Invalid command: start

/opt/mongodb/bin/mongod/ --logpath /opt/mongodb/bin
-bash: /opt/mongodb/bin/mongod/: Not a directory

/opt/mongodb/bin/mongod/ --logpath /opt/mongodb/bin/mongod/
-bash: 2b.: command not found

/opt/mongodb/bin/mongod/ --logpath /opt/mongodb/bin/mongod
-bash: /opt/mongodb/bin/mongod/: Not a directory

任何帮助/指导都是最有用的

4

1 回答 1

0

The Mongo::ConnectionFailure error for localhost:27017 is typical when mongod is not running. You should check for this using the ps command, restart mongod if necessary, and then run the mongo shell. If the mongo shell reports "Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84" then go back and check the status of your mongod server process.

The following lines are suspicious.

/opt/mongodb/bin/mongod --fork --logpath /opt/mongodb/bin
/opt/mongodb/bin/mongod --repair

It appears that you are trying to run the mongod server and repair at the same time. The repair attempt will bail out if mongod is already running, and I'm guessing that you really intended to run it before starting db service. If you are on a 64-bit platform, journaling is on by default and you should not do a repair to recover a consistent state, see http://www.mongodb.org/display/DOCS/Durability+and+Repair

Also, repair can take a long time, and during this time, you cannot start another mongod for db service. I suspect that this is your underlying problem - that repair was running, causing attempts to start db service to fail.

Regardless, it appears that mongod is not running. Options like --start, --status, start are all unknown as stated, and mongod also prints a full list of options for each of these errors. Having a trailing slash after a shell command (after mongo) is telling the OS to look for a directory. Did you try to execute mongod in the shell with no options? What happens? You need to get mongod running as a db server (not repair) and should verify that it is up and that you can connect using the mongo shell before you go any further.

Let us know how it works out.

于 2012-06-08T15:32:04.227 回答