ActiveRecord :: JDBCError:错误:无法打开扩展控制文件

时间:2013-01-26 21:06:54

标签: ruby-on-rails postgresql jruby

这可能是Google界面问题的主席,但我还无法发现任何内容。任何指针都会有所帮助。

JRuby 1.6.8 Rails 3.2.11 Postgres 9.1 Ubuntu 12.04

我有一个RAILS迁移:

class AddDblinkToEnrollmentsShards < ActiveRecord::Migration
  db_magic :connections => [:enrollments_shard_one, :enrollments_shard_two, :enrollments_shard_three, :enrollments_shard_four]

  def change
    execute "CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;"
  end
end

我一直收到这个错误:

-- execute("CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;")
  [enrollments_shard_one]   (16.0ms)  CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
ActiveRecord::JDBCError: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/dblink.control": No such file or directory: CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
==  AddDblinkToEnrollmentsShards: Switching connection back ===================
rake aborted!
An error has occurred, this and all later migrations canceled:

ActiveRecord::JDBCError: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/dblink.control": No such file or directory: CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
arjdbc/jdbc/RubyJdbcConnection.java:195:in `execute'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:217:in `_execute'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:209:in `execute'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `log'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activesupport-3.2.11/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/rails3/abstract_adapter/connection_name.rb:14:in `instrument'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/instrumentation/active_record.rb:32:in `log_with_newrelic_instrumentation'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:240:in `trace_execution_scoped'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/instrumentation/active_record.rb:29:in `log_with_newrelic_instrumentation'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:209:in `execute'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2130:in `send'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:466:in `method_missing'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `say_with_time'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `say_with_time'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:458:in `method_missing'
/home/scott/source/unicon/unicon-ttm-sandbox/db/migrate/20130103134257_add_dblink_to_enrollments_shards.rb:5:in `change'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:407:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:407:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:389:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:86:in `migrate_with_db_wrapper'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:125:in `on_db'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:123:in `on_db'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:85:in `migrate_with_db_wrapper'
org/jruby/RubyArray.java:1620:in `each'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:84:in `migrate_with_db_wrapper'
org/jruby/RubyBasicObject.java:1704:in `__send__'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:528:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:720:in `migrate'
org/jruby/RubyProc.java:258:in `call'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `ddl_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:491:in `transaction_with_trace_ActiveRecord_self_name_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:240:in `trace_execution_scoped'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:486:in `transaction_with_trace_ActiveRecord_self_name_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `ddl_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:719:in `migrate'
org/jruby/RubyArray.java:1620:in `each'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:570:in `up'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:557:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:179:in `(root)'
org/jruby/RubyProc.java:258:in `call'
org/jruby/RubyArray.java:1620:in `each'
org/jruby/RubyArray.java:1620:in `each'
org/jruby/RubyKernel.java:1097:in `load'
org/jruby/RubyKernel.java:1117:in `eval'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bin/ruby_noexec_wrapper:14:in `(root)'

3 个答案:

答案 0 :(得分:3)

dblink扩展程序未在此系统上安装主PostgreSQL程序包,因此用户必须单独安装它。见评论。

答案 1 :(得分:1)

在CentOS上:

sudo yum install postgres*contrib

登录数据库,运行:

CREATE EXTENSION dblink;

答案 2 :(得分:1)

对于安装了多个pg版本的实例,用户还需要通过指定版本来安装contrib包:

sudo apt-get install postgresql-contrib-9.1