在VPS上为rails生产设置postgres

时间:2013-03-05 14:13:29

标签: ruby-on-rails postgresql activerecord

我目前正在VPS上设置一个rails应用程序,直到现在这个过程还很顺利。 rails连接到我的生产数据库时似乎存在问题。

到目前为止我尝试了什么: 创建“test”用户和生产数据库“nn_production”:

$ sudo -u postgres createuser -D -P test
$ sudo -u postgres createdb -O test nn_production;

\l gives:
     Name      |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
---------------+----------+----------+-------------+-------------+-----------------------
 nn_production | test     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |

此外在/etc/postgresql/9.1/main/pg_hba.conf from related SO question

我只改变了这一行:

local   all             all                                     peer

到此:

local   all             all                                     md5

我尝试了以下操作,并且有效。

$ psql -d nn_production -U test -W

这是我的database.yml

production:
adapter: postgresql
encoding: unicode
database: nn_production
min_messages: ERROR
pool: 5
host: localhost
username: test
password: test

我使用了capistrano而且我在/ u / apps / nn / current

现在我尝试:

$ rake RAILS_ENV=production db:schema:load

我得到了臭名昭着的

ActiveRecord::ConnectionNotEstablished

我非常感谢任何指针。如果丢失一些重要信息只会对我大喊大叫。

修改:cat /var/log/postgresql/postgresql-9.2-main.log

2013-03-05 14:32:55 CET LOG:  received fast shutdown request
2013-03-05 14:32:55 CET LOG:  aborting any active transactions
2013-03-05 14:32:55 CET LOG:  autovacuum launcher shutting down
2013-03-05 14:32:55 CET LOG:  shutting down
2013-03-05 14:32:55 CET LOG:  database system is shut down
2013-03-05 14:32:56 CET LOG:  database system was shut down at 2013-03-05 14:32:55 CET
2013-03-05 14:32:56 CET LOG:  autovacuum launcher started
2013-03-05 14:32:56 CET LOG:  database system is ready to accept connections
2013-03-05 14:32:57 CET LOG:  incomplete startup packet

设定:

  • Ubuntu 12.10
  • RVM
  • ruby​​ 1.9.3
  • rails version 3.2.12
  • pg gem 0.14.1

1 个答案:

答案 0 :(得分:1)

我觉得自己像个白痴。 database.yaml中的缩进很重要。浪费的总时数:8。

相关问题