1

現在取り組んでいるRailsアプリがあります。私はubuntu12.10を使用してlinodeサーバーにデプロイしましたが、「申し訳ありませんが、問題が発生しました」という素敵なメッセージが表示されます。メッセージ。何が間違っている可能性があるかを示すためにログファイル内を調べてきましたが、エラーをスローしているようには見えません。

既知

  1. 開発モードと本番モードの両方でローカルに動作します
  2. エラーログには、データベースへのアクセス以外は何も書かれていません
  3. rake db:migrateデータベース構成でアダプターが指定されていない
  4. RAILS_ENV = product 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"}
4

3 に答える 3

1

暗闇の中で突き刺す...「デプロイヤー」がOSユーザーだと思いますか?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 に答える
1

ローカルのUNIXユーザーには、postgresqlソケットへのアクセス許可がありません。これを修正するには、ローカルアクセスを許可し、編集/etc/postgresql/main/pg_hba.confして、#"local"に関するコメントの後に次を追加する必要があります。

local all         all                 trust

これにより、このマシン上のすべてのローカルユーザーにアクセスが許可されます。

ファイルを保存してPostgresqlを再起動します。

于 2012-11-15T02:43:00.397 に答える
0

database.ymlの本番構成はどのようになっていますか?「デプロイヤー」があると指定したユーザーのようですが、クラスター内のユーザーが前述のように「タスク」である場合は正しくありません。そこにあるユーザー名とパスワードが正しい場合は、他のクライアントを介してクラスターに接続しようとすることからトラブルシューティングを開始します。個人的な好みは、psqlユーティリティを使用することです。このように接続できます(psqlがパスにあると仮定します)-

psql -h localhost -U deployer postgres

「postgres」データベースは、デフォルトで新しいデータクラスターに作成されます。別のクライアントに接続できるようになったら、必要な変更を加えてdatabase.ymlの本番構成を更新し、再試行します。

于 2012-11-15T02:41:40.727 に答える