转自:https://stackoverflow.com/questions/14541576/activerecordjdbcerror-error-could-not-open-extension-control-file
<span style="color:var(--highlight-color)"><code><span style="color:var(--highlight-comment)">-- execute("CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;")</span>
[enrollments_shard_one] (16.0ms) <span style="color:var(--highlight-keyword)">CREATE</span> EXTENSION <span style="color:var(--highlight-keyword)">IF</span> <span style="color:var(--highlight-keyword)">NOT</span> <span style="color:var(--highlight-keyword)">EXISTS</span> dblink <span style="color:var(--highlight-keyword)">WITH</span> <span style="color:var(--highlight-keyword)">SCHEMA</span> <span style="color:var(--highlight-keyword)">public</span>;
ActiveRecord::JDBCError: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/dblink.control": No such file or directory: <span style="color:var(--highlight-keyword)">CREATE</span> EXTENSION <span style="color:var(--highlight-keyword)">IF</span> <span style="color:var(--highlight-keyword)">NOT</span> <span style="color:var(--highlight-keyword)">EXISTS</span> dblink <span style="color:var(--highlight-keyword)">WITH</span> <span style="color:var(--highlight-keyword)">SCHEMA</span> <span style="color:var(--highlight-keyword)">public</span>;
== 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: <span style="color:var(--highlight-keyword)">CREATE</span> EXTENSION <span style="color:var(--highlight-keyword)">IF</span> <span style="color:var(--highlight-keyword)">NOT</span> <span style="color:var(--highlight-keyword)">EXISTS</span> dblink <span style="color:var(--highlight-keyword)">WITH</span> <span style="color:var(--highlight-keyword)">SCHEMA</span> <span style="color:var(--highlight-keyword)">public</span>;
arjdbc/jdbc/RubyJdbcConnection.java:195:in `<span style="color:var(--highlight-keyword)">execute</span><span style="color:var(--highlight-variable)">'</span></code></span>
在CentOS上:
sudo yum install postgres*contrib
录数据库,运行:
CREATE EXTENSION dblink;
对于安装了多个pg版本的实例,用户还需要通过指定版本来安装contrib软件包:
sudo apt-get install postgresql-contrib-9.1