1

我有一个我目前正在开发的 Rails 应用程序。我已经使用 ubuntu 12.10 部署到 linode 服务器,并且收到了一个可爱的“我们很抱歉,但出了点问题”。信息。我一直在查看日志文件中是否有任何可能出现问题的迹象,但似乎没有任何错误发生。

已知

  1. 在开发和生产模式下本地工作
  2. 错误日志除了访问数据库之外什么也没说
  3. rake db:migrate 数据库配置未指定适配器
  4. RAILS_ENV=production rake db:create 导致用户“部署者”的密码认证失败
  5. postgresql 中的用户/所有者是“任务”,密码与我在 database.yml 中的密码匹配

我一直在寻找 stackoverflow 试图找到任何相关的错误,但我还没有找到有效的解决方案。

在此先感谢您的时间。

.

deployer@Asphodel:~/apps/TaskWebsite/current$ RAILS_ENV=production rake db:create
FATAL:  password authentication failed for user "deployer"
FATAL:  password authentication failed for user "deployer"
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `initialize'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `new'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `connect'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:329:in `initialize'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:309:in `new_connection'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:319:in `checkout_new_connection'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:241:in `block (2 levels) in checkout'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `loop'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `block in checkout'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:233:in `checkout'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in `block in connection'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:404:in `retrieve_connection'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:170:in `retrieve_connection'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:144:in `connection'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:107:in `rescue in create_database'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:51:in `create_database'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:40:in `block (3 levels) in <top (required)>'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:40:in `each'
/home/deployer/apps/TaskWebsite/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:40:in `block (2 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"tasks_production", "pool"=>5, "host"=>"localhost", "user"=>"tasks", "password"=>"blahblah"}
4

3 回答 3

1

您的本地 unix 用户没有权限访问您的 postgresql 套接字。要解决此问题,您应该授予本地访问权限,编辑/etc/postgresql/main/pg_hba.conf并在关于 # "local" 的评论后添加:

local all         all                 trust

这将授予此计算机上的所有本地用户的访问权限。

保存文件并重新启动 Postgresql - 你应该很高兴。

于 2012-11-15T02:43:00.397 回答
1

在黑暗中刺伤......猜测“部署者”是操作系统用户?Postgres 的 pg_hba.conf 文件是什么样的?

http://www.postgresql.org/docs/9.2/static/auth-pg-hba-conf.html

也许您只允许来自本地主机的“对等”?看一下特别像下面这样的部分......

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
于 2012-11-15T02:42:29.537 回答
0

您的 database.yml 中的生产配置是什么样的?看起来指定的用户有“部署者”,如果集群中的用户是你提到的“任务”,那将是不正确的。如果用户名和密码正确,我会尝试通过其他客户端连接到集群来开始故障排除——我个人的偏好是只使用 psql 实用程序。您可以像这样连接(假设 psql 在您的路径中) -

psql -h localhost -U deployer postgres

“postgres”数据库默认创建在一个新的数据集群中。一旦您可以连接到不同的客户端,请使用任何必要的更改更新您的 database.yml 中的生产配置,然后重试。

于 2012-11-15T02:41:40.727 回答