Postgres只是随机停止工作(Rails,PGSQL.5432) [英] Postgres just randomly stopped working (Rails, PGSQL.5432)

查看:89
本文介绍了Postgres只是随机停止工作(Rails,PGSQL.5432)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在同一应用程序中使用相同的Postgres数据库一个月了,没有任何问题,并且在今天随机出现此错误之前,我没有更改数据库中的任何内容。但是,今天Postgres在尝试 rails s时随机开始引发此错误(在运行createdb或createuser时出现相同类型的错误):

I've been using the same Postgres database in this same app for a month with no problems, and I didn't change anything in the database before this error randomly came up today. However, today Postgres randomly started throwing this error when I try to "rails s" (I get the same type of error when running createdb or createuser):

退出
/Users/Joe/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1194:in'initialize':无法连接到服务器:没有这样的文件或目录(PG :: Error)
服务器是否在本地运行并且在Unix域套接字 /tmp/.s.PGSQL.5432上接受
连接?

Exiting /Users/Joe/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:1194:in `initialize': could not connect to server: No such file or directory (PG::Error) Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

真正奇怪的是我的朋友昨天有完全相同的错误(在同一应用程序上工作),并且由他从 http://nextmarvel.net/blog/2011/09/brew-install-postgresql- on-os-x-lion / 。运行脚本后,他卸载并重新安装了PG gem,以使一切正常。但是,他正在运行OS X Lion,而我正在运行Snow Leopard,因此该脚本对我不起作用。

What's really weird is that my friend had the exact same errors yesterday (working on the same app), and it was fixed by him running the script from http://nextmarvel.net/blog/2011/09/brew-install-postgresql-on-os-x-lion/. After running the script, he uninstalled and reinstalled the PG gem to make everything work. However, he is running OS X Lion, and I am running Snow Leopard, so that script wouldn't work for me.

关于(1)为什么这样做的任何想法随机开始发生,以及(2)如何解决?

Any ideas of (1) why this would randomly start happening and (2) how to fix it?

推荐答案

我今天遇到了类似的问题,尽管就我而言,postgres(通过MacOS 10.8上的自制软件安装)没有运行,但是我无法启动或重新启动它。看来,由于崩溃,僵尸阻塞了套接字,要解决该问题,我做了以下

I had a similar problem today, although in my case postgres (installed via homebrew on MacOS 10.8) wasn't running but I couldn't start or restart it. It appeared that due to a crash a zombie was blocking the socket, to resolve it i did the following

lsof -i :5432

这显示了进程阻塞的PID,我只是用

this showed the PID of the process blocking, I simply killed it with

kill -9 PID

和postgres重新启动正常。

and postgres restarted fine.

HTH

这篇关于Postgres只是随机停止工作(Rails,PGSQL.5432)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆