【问题标题】:Unable to fetch tables information when running heroku db:pull运行 heroku db:pull 时无法获取表信息
【发布时间】:2012-09-16 20:30:16
【问题描述】:

我有一个在开发和生产中使用 postgres 的应用程序。我最近推到heroku,一切正常。我能够从 heroku 中提取数据库并毫无问题地向上推。然而今天,我试图从 heroku 中拉下数据库,我收到了这个错误

heroku db:pull

Loaded Taps v0.3.24
    Auto-detected local database: postgres://postgres:a@127.0.0.1/app_development?encoding=utf8
    Warning: Data in the database 'postgres://postgres:a@127.0.0.1/app_development?encoding=utf8' will be overwritten and will not be recoverable.

     !    WARNING: Destructive Action
     !    This command will affect the app: app
     !    To proceed, type "app" or re-run this command with --confirm app

    > app
Receiving schema
Unable to fetch tables information from http://heroku:osui59a24am79x@taps19.heroku.com. Please check the server log.

所以我在之后运行heroku logs

james@james-Vostro-3550:~/Desktop/app$ heroku logs
2012-09-25T10:08:32+00:00 app[web.1]: Started GET "/users" for X.X.X.X at 2012-09-25 10:08:32 +0000
2012-09-25T10:08:32+00:00 heroku[router]: GET app.herokuapp.com/users? dyno=web.1 queue=0 wait=0ms service=38ms status=200 bytes=10727
2012-09-25T10:08:32+00:00 app[web.1]: 
2012-09-25T10:08:32+00:00 app[web.1]: 
2012-09-25T10:08:32+00:00 app[web.1]: Started GET "/application.css" for X.X.X.X at 2012-09-25 10:08:32 +0000
2012-09-25T10:08:32+00:00 app[web.1]: 
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2012-09-25T10:08:32+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/application.css"):
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/logger.rb:26:in `call_app'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/logger.rb:16:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-09-25T10:08:32+00:00 heroku[router]: GET app.herokuapp.com/application.css dyno=web.1 queue=0 wait=0ms service=6ms status=404 bytes=728
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/static.rb:62:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/engine.rb:479:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/application.rb:220:in `call'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in `method_missing'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:78:in `catch'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:80:in `block in pre_process'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:53:in `process'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:78:in `pre_process'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:38:in `receive_data'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/backends/base.rb:63:in `start'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/server.rb:159:in `start'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/controllers/controller.rb:86:in `start'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:185:in `run_command'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:151:in `run!'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/bin/thin:6:in `<top (required)>'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
2012-09-25T10:08:32+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main>'
2012-09-25T10:08:32+00:00 app[web.1]: 
2012-09-25T10:08:32+00:00 app[web.1]: 
2012-09-25T10:08:32+00:00 heroku[router]: GET app.herokuapp.com/assets/admin-e0756c8b3550bb800d5f58837c42ec80.css dyno=web.1 queue=0 wait=0ms service=7ms status=200 bytes=1941
2012-09-25T10:08:32+00:00 app[web.1]: 
2012-09-25T10:08:32+00:00 app[web.1]: 
2012-09-25T10:08:32+00:00 app[web.1]: Started GET "/assets/admin-e0756c8b3550bb800d5f58837c42ec80.css" for X.X.X.X at 2012-09-25 10:08:32 +0000
2012-09-25T10:08:41+00:00 app[web.1]: 
2012-09-25T10:08:41+00:00 app[web.1]: 
2012-09-25T10:08:41+00:00 app[web.1]: Started GET "/projects" for X.X.X.X at 2012-09-25 10:08:41 +0000
2012-09-25T10:08:41+00:00 heroku[router]: GET app.herokuapp.com/projects dyno=web.1 queue=0 wait=0ms service=31ms status=304 bytes=0
2012-09-25T10:08:41+00:00 app[web.1]: Started GET "/application.css" for X.X.X.X at 2012-09-25 10:08:41 +0000
2012-09-25T10:08:41+00:00 app[web.1]: 
2012-09-25T10:08:41+00:00 app[web.1]: 
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2012-09-25T10:08
:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-09-25T10:08:41+00:00 app[web.1]: 
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-09-25T10:08:41+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/application.css"):
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/logger.rb:26:in `call_app'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/logger.rb:16:in `call'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in `method_missing'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/static.rb:62:in `call'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/application.rb:220:in `call'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/server.rb:159:in `start'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:78:in `catch'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/engine.rb:479:in `call'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:80:in `block in pre_process'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:53:in `process'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/backends/base.rb:63:in `start'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:78:in `pre_process'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/connection.rb:38:in `receive_data'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:151:in `run!'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/runner.rb:185:in `run_command'
2012-09-25T10:08:41+00:00 app[web.1]: 
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main>'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/lib/thin/controllers/controller.rb:86:in `start'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.4.1/bin/thin:6:in `<top (required)>'
2012-09-25T10:08:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
2012-09-25T10:08:41+00:00 app[web.1]: 
2012-09-25T10:08:41+00:00 heroku[router]: GET app.herokuapp.com/application.css dyno=web.1 queue=0 wait=0ms service=9ms status=404 bytes=728
2012-09-25T10:11:00+00:00 heroku[run.1]: Awaiting client
2012-09-25T10:11:00+00:00 heroku[run.1]: Starting process with command `bundle exec rake db:migrate`
2012-09-25T10:11:00+00:00 heroku[run.1]: State changed from starting to up
2012-09-25T10:11:06+00:00 heroku[run.1]: Client connection closed. Sending SIGHUP to all processes
2012-09-25T10:11:07+00:00 heroku[run.1]: Process exited with status 1
2012-09-25T10:11:07+00:00 heroku[run.1]: State changed from up to complete
2012-09-25T10:08:23+00:00 heroku[web.1]: State changed from starting to up
2012-09-25T10:08:01+00:00 heroku[web.1]: Unidling
2012-09-25T10:08:01+00:00 heroku[web.1]: State changed from down to starting

我不知道在哪里寻找解决方案,所以希望有人能提供帮助。我刚开始学习 Rails,所以在尝试提供帮助时请记住这一点。

提前致谢。

编辑:

我尝试了各种方法: 重新安装heroku,点击。 重新制作我的应用程序并推送到heroku。 重新安装 postgres。

似乎没有任何效果。快把我逼疯了!

【问题讨论】:

  • 你有没有重试看看是否是可重现的错误?我有时会在 db:push 和 pull 上遇到故障,但很少见,并且通常会重试,似乎是短时间的服务器不稳定。
  • 日志中的错误与DB无关,它说找不到application.css,可能是资产管道有问题。
  • 我已经重试了几次,得到了同样的错误。站点仍然可以在线运行,但我无法提取数据库。日志似乎没有显示有数据库拉取尝试。
  • 今天早上我遇到了完全相同的问题。在我的日志中看不到任何东西。也许 Heroku 有问题?
  • 嗯,我可以在 google 中找到很多关于此错误的提及,但任何地方都没有真正的解决方案。

标签: ruby-on-rails ruby database heroku pull


【解决方案1】:

我刚收到 heroku 的答复。他们说他们在使用水龙头时遇到了一些问题,现在它又可以正常工作了。

我检查并确认它对我有用。

Rgds,

【讨论】:

    【解决方案2】:

    我找到了某种解决方法。
    我在 heroku 上的 SHARED_DATABASE 遇到了同样的问题
    红宝石 1.9.2
    宝石:
    pg (0.11.0)
    heroku (2.32.4)
    heroku-api (0.3.5)
    水龙头 (0.3.24)
    heroku db:pull 以:
    结尾 无法从 http://...@taps19.heroku.com 获取表信息。请检查服务器日志。

    我使用 rvm 切换到 ruby​​ 1.8.7,heroku db:pull 工作正常。
    再次回到 ruby​​ 1.9.2 来开发我的应用程序。

    我希望这对某人有所帮助,直到 db:pull 将被 ruby​​ 1.9.2 修复。

    【讨论】:

    • 也适合我。谢谢!在 ruby​​ 1.9.2 找到解决方案之前,我仍然不会回答这个问题
    • 使用 1.9.3-p194,水龙头突然停止工作。我继续在本地使用 MySQL,因为 Sequel Pro 非常简单,而不是使用 pgbackups。这个答案对我有用。谢谢
    【解决方案3】:

    MySQL

    (关于 PostgreSQL 的说明在页面下方)

    临时解决方法是直接从数据库服务器转储数据并自行手动加载。我在 MySQL 中有两个数据库(在 Heroku 和本地),所以我做到了:

    1. mysqldump -h host -P port_number -u user_name_to_your_db -p your_db_name > data.sql
    

    使用正确的详细信息运行上述命令后,系统会要求您输入密码。

    注意:切勿将您的密码输入您的 shell 命令,因为它已存储在 shell 命令历史记录中。

    从 Heroku 配置中获取您的 usernamepasswordyour_db_namehostport_number

    2. heroku config --app your-app-name | grep DATABASE_URL
    

    您的DATABASE_URL 将如下所示:

    mysql2://username:password@host:port_number/your_db_name
    

    更真实的DATABASE_URL 的示例如下所示(那里的登录详细信息已修改):

    mysql2://afdgsdfghliue:ESIJAFDG-sAFsgiags3464@ec2-34-15-23-232.compute-2.amazonaws.com:5432/9twgsenr8543
    

    在那种情况下,细节将分别是(记住,这些是假的):

    username: afdgsdfghliue:ESIJAFDG
    password: ESIJAFDG-sAFsgiags3464
    host:     ec2-34-15-23-232.compute-2.amazonaws.com
    port:     5432
    database: 9twgsenr8543
    

    当您使用1. 中所示的正确详细信息运行mysqldump 时,您的数据将存储在本地data.sql 中。现在要将其加载到本地数据库(我们仍在讨论 MySQL),您需要运行:

    mysql -u your_local_db_username -h 127.0.0.1 -p your_local_db_name < data.sql
    

    您应该拥有的本地数据库登录详细信息。

    PostgreSQL

    我自己没有检查过以下说明,所以请结合你的大脑使用它们;-)

    我从

    找到的
    pg_dump --help 
    

    您可以像这样运行类似的命令从 Heroku 转储 PostgreSQL 数据库:

    pg_dump -h host -p port -U username -W your_db_name > data.sql
    

    您的DATABASE_URL 将以postgres 开头:

    postgres://username:password@host:port_number/your_db_name
    

    基于

    psql --help
    

    这里是如何从上面准备的data.sql 文件加载本地 PostgreSQL 数据库:

    psql -h 127.0.0.1 -U your_local_db_username -W -d your_local_db_name -f data.sql
    

    有点手动的过程,但它至少能让你继续前进。

    【讨论】:

    • 我尝试了你的建议,我遇到了一些麻烦。不打算深入讨论,因为我只想让heroku db:pull 再次工作
    • 我也想heroku db:pull再次工作。我在help.heroku.com 上提交了一张票,所以也许他们会做点什么。但现在,上述解决方案让我可以继续我的工作。
    猜你喜欢
    • 2013-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-20
    • 2013-04-29
    相关资源
    最近更新 更多