【问题标题】:Upgrading postgres database files fail with "could not access file $libdir/postgis-2.5: No such file or directory"升级 postgres 数据库文件失败并显示“无法访问文件 $libdir/postgis-2.5:没有这样的文件或目录”
【发布时间】:2020-11-12 23:29:29
【问题描述】:

我正在使用 OSX 并通过 Homebrew 安装了 postgres。我刚刚将 Postgres 从 v11 升级到 v13。现在我尝试使用以下方法更新数据库文件:

brew postgresql-upgrade-database

这失败了,查看日志,错误是:

pg_dump: error: query failed: ERROR:  could not access file "$libdir/postgis-2.5": No such file or directory

如果我这样做brew info postgis,那么我会看到:

% brew info postgis
postgis: stable 3.0.2 (bottled), HEAD
Adds support for geographic objects to PostgreSQL
https://postgis.net/
/usr/local/Cellar/postgis/3.0.2_1 (435 files, 29.7MB) *
  Poured from bottle on 2020-11-12 at 23:15:12
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/postgis.rb
License: GPL-2.0-or-later
==> Dependencies
Build: gpp ✘, pkg-config ✔
Required: gdal ✔, geos ✔, json-c ✔, pcre ✔, postgresql ✔, proj ✔, protobuf-c ✔, sfcgal ✔
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 11,064 (30 days), 26,959 (90 days), 80,033 (365 days)
install-on-request: 10,946 (30 days), 26,628 (90 days), 78,351 (365 days)
build-error: 0 (30 days)

所以我猜 Postgis 3.0.2 是作为升级过程的一部分安装的,而 pg_dump(数据库文件升级需要它)找不到 Postgis 2.5。

我该怎么办?我想我可以暂时将 Postgis 2.5 重新安装到 $libdir - 但是如何?

pg_config --pkglibdir 表明$libdir/usr/local/lib/postgresql。如果我列出该目录中的文件,我可以看到它包含postgis-3.so,但不包含postgis-2.5.so

注意:我目前也无法使用 psql 访问 postgres - 我看到了可怕的 psql: error: could not connect to server: could not connect to server: No such file or directory。但是,brew services list 告诉我 postgresql 正在运行。

【问题讨论】:

    标签: postgresql postgis


    【解决方案1】:

    如果您还没有卸载错误版本的 Postgis:

    brew remove postgis
    

    这里先到最后2.5版本的Postgis公式:

    https://raw.githubusercontent.com/Homebrew/homebrew-core/bca96164362bfa3c42b4d403be4eb3847797424f/Formula/postgis.rb

    复制该代码。

    将此粘贴​​到您机器上的自制 Postgis 公式上:

    pbpaste > $(find $(brew --repository) -name postgis.rb)
    

    然后用这个公式再次安装 Postgis:

    brew install postgis
    

    Pin Postgis 以防止它被意外升级:

    brew pin postgis
    

    这应该会为您提供正确版本的 Postgis。

    【讨论】:

      【解决方案2】:

      升级 PostGIS 并不那么简单(请参阅文档),并且通过使用此发行版的自动升级,您可能会弄乱您的安装。

      完整备份您的 PostgreSQL 数据目录,然后卸载 PostgreSQL v13,再次安装 v11 和 PostGIS 2.5,看看您可以让数据库再次工作。

      然后按照 PostGIS 手册中的升级程序进行操作。

      【讨论】:

      • 谢谢。我正在为“再次安装 PostGIS 2.5”部分而苦苦挣扎。 Homebrew 只知道 PostGIS 3.0。
      • 这很难。不幸的是,我不了解 Mac OS,因此我无法告诉您是否有特定于自制软件的解决方案。我可以想到两种方法:1)从备份中恢复机器 2)从源代码安装 PostGIS(这很困难,因为它依赖于许多其他软件,您需要为此安装头文件)。
      【解决方案3】:

      在 PostGIS 站点链接的用户 wiki 上有一个兼容性/支持矩阵,这似乎表明从 Postgres v13 开始,PostGIS 的最低版本是 v3.0

      如果您因任何原因无法使用 PostGIS v2.5,Postgres V12 似乎是您的最佳选择。

      【讨论】:

      • 看起来这不是真的,但建议使用 Postgres 13:“PostGIS 团队很高兴发布即将发布的 PostGIS 3.1.0 版本的第一个测试版。这个版本暴露了一些新的性能以及尚未发布的 GEOS 3.9 中的功能增强以及不需要更新的 GEOS 的大量速度增强。需要 GEOS 3.6+ 和 PostgreSQL 9.6+。要使用 MVT,您需要 protobuf-c 1.1. 或更高版本。"
      猜你喜欢
      • 1970-01-01
      • 2014-01-16
      • 2021-06-19
      • 2011-03-23
      • 2020-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多