ruby-on-rails - 已部署的 Rails 应用程序出现 Postgresql 错误

标签 ruby-on-rails postgresql deployment linode

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

已知

  1. 在本地以开发和生产模式工作
  2. 错误日志除了访问数据库什么都没说
  3. rake db:migrate 数据库配置没有指定适配器
  4. RAILS_ENV=production rake db:create 导致用户“deployer”的密码验证失败
  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"}

最佳答案

暗中刺探……猜测“部署者”是操作系统用户? 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

关于ruby-on-rails - 已部署的 Rails 应用程序出现 Postgresql 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13390730/

相关文章:

Spring hibernate 插入竞争条件

sql - 在 Postgres 中将数字四舍五入到最接近的 10

ruby-on-rails - 使用 sudo 设置 Ruby on Rails 是否被认为是一种不好的做法?

.net - 更新或版本控制 Web 服务的策略?

kubernetes - 如何对两个依赖部署执行滚动更新,其中一个部署具有较长的宽限期?

ruby-on-rails - 如何从任何文件夹查看 Rails 中的文件列表,外部 Rails.root - Windows

ruby-on-rails - 在 ActiveRecord 模型的 Elasticsearch 索引之间共享设置(轮胎 gem)

ruby-on-rails - Ruby on Rails - 从模型访问 Controller 变量

ruby-on-rails - ruby strptime 错误

.net - 由于 ZIP 结构,使用 kudu ZipDeploy 的 Azure Web 应用程序部署失败