从 postgresql 9.3 迁移到 9.4,postgis
migrating from postgresql 9.3 to 9.4, postgis
我从 postgresql 9.3 升级到 9.4,现在我想迁移我的数据。
这就是我尝试做的。首先我运行老postgresql是这样
/opt/pgsql-9.3/bin/pg_ctl -D /var/lib/postgres/data/ start
然后,我尝试将旧数据库转储到文件中:
/opt/pgsql-9.3/bin/pg_dumpall >> old_backup.sql
它告诉我:
pg_dump: [archiver (db)] query failed: ERROR: could not access file "$libdir/postgis-2.1": No such file or directory
好吧,我试着找到 postgis-2.1 文件并将它们复制到 libdir
find / -name "*postgis-2.1*"
/usr/lib/postgresql/rtpostgis-2.1.so
/usr/lib/postgresql/postgis-2.1.so
/usr/lib/postgresql/postgis-2.1 <-----
好的,现在 libdir
是什么?
/opt/pgsql-9.3/bin/pg_config --pkglibdir
/opt/pgsql-9.3/lib
所以我在/opt/pgsql-9.3/lib
中做了一个符号link到here /usr/lib/postgresql/postgis-2.1
:
pwd
/opt/pgsql-9.3/lib
ls -l postgis-2.1
postgis-2.1 -> /usr/share/postgresql/contrib/postgis-2.1
但我仍然收到错误:查询失败:错误:无法访问文件“$libdir/postgis-2.1”:没有这样的文件或目录
我有点没主意了。也许有人可以帮助我?
我是 usnig arch linux
P.S
已安装 Postgis:
pacman -S postgis
warning: postgis-2.1.5-1 is up to date -- reinstalling
这里是二进制文件:
find / -name "*postgis-2.1*"
/usr/lib/postgresql/rtpostgis-2.1.so <---- binary
/usr/lib/postgresql/postgis-2.1.so <----- binary
/opt/pgsql-9.3/lib/postgis-2.1 <----- that's the symlink from earlier
/usr/share/postgresql/contrib/postgis-2.1
符号 link 指向 "share" 文件,用于 CREATE EXTENSION
和家庭。您需要将 .so
文件指向 pg_config --pkglibdir
:
返回的目录中
$ rm /opt/pgsql-9.3/lib/postgis-2.1 # it is a wrong link, so undo it
$ ln -s /usr/lib/postgresql/postgis-2.1.so /opt/pgsql-9.3/lib/
现在 PostGIS .so
文件将在 "$libdir"
中,您将能够执行 pg_dumpall
.
当然,保持这种方式并不会给我留下深刻的印象,但作为您的升级,我假设这只是一个中间状态,之后您将完全删除 PostgreSQL 9.3。您还必须验证 PostGIS 是否 link 与 9.3 库一起使用,否则您可能会遇到一些问题。
我有类似的问题,但解决方法有点不同:
dbname=#\dx
Name | Version | Schema | Description
---------+---------+------------+---------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
postgis | 2.1.5 | postgis | PostGIS geometry, geography, and raster spatial types and functions
dbname=#ALTER EXTENSION postgis UPDATE TO '2.2.0';
dbname=#\dx
Name | Version | Schema | Description
---------+---------+------------+---------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
postgis | 2.2.0 | postgis | PostGIS geometry, geography, and raster spatial types and functions
我遇到了同样的问题。我对 Docker 的解决方案是:
docker exec -i $(docker-compose ps -q postgis) ln -s /usr/lib/postgresql/9.6/lib/postgis-2.3.so /usr/lib/postgresql/9.6/lib/postgis-2.1.so
我从 postgresql 9.3 升级到 9.4,现在我想迁移我的数据。
这就是我尝试做的。首先我运行老postgresql是这样
/opt/pgsql-9.3/bin/pg_ctl -D /var/lib/postgres/data/ start
然后,我尝试将旧数据库转储到文件中:
/opt/pgsql-9.3/bin/pg_dumpall >> old_backup.sql
它告诉我:
pg_dump: [archiver (db)] query failed: ERROR: could not access file "$libdir/postgis-2.1": No such file or directory
好吧,我试着找到 postgis-2.1 文件并将它们复制到 libdir
find / -name "*postgis-2.1*"
/usr/lib/postgresql/rtpostgis-2.1.so
/usr/lib/postgresql/postgis-2.1.so
/usr/lib/postgresql/postgis-2.1 <-----
好的,现在 libdir
是什么?
/opt/pgsql-9.3/bin/pg_config --pkglibdir
/opt/pgsql-9.3/lib
所以我在/opt/pgsql-9.3/lib
中做了一个符号link到here /usr/lib/postgresql/postgis-2.1
:
pwd
/opt/pgsql-9.3/lib
ls -l postgis-2.1
postgis-2.1 -> /usr/share/postgresql/contrib/postgis-2.1
但我仍然收到错误:查询失败:错误:无法访问文件“$libdir/postgis-2.1”:没有这样的文件或目录
我有点没主意了。也许有人可以帮助我?
我是 usnig arch linux
P.S
已安装 Postgis:
pacman -S postgis
warning: postgis-2.1.5-1 is up to date -- reinstalling
这里是二进制文件:
find / -name "*postgis-2.1*"
/usr/lib/postgresql/rtpostgis-2.1.so <---- binary
/usr/lib/postgresql/postgis-2.1.so <----- binary
/opt/pgsql-9.3/lib/postgis-2.1 <----- that's the symlink from earlier
/usr/share/postgresql/contrib/postgis-2.1
符号 link 指向 "share" 文件,用于 CREATE EXTENSION
和家庭。您需要将 .so
文件指向 pg_config --pkglibdir
:
$ rm /opt/pgsql-9.3/lib/postgis-2.1 # it is a wrong link, so undo it
$ ln -s /usr/lib/postgresql/postgis-2.1.so /opt/pgsql-9.3/lib/
现在 PostGIS .so
文件将在 "$libdir"
中,您将能够执行 pg_dumpall
.
当然,保持这种方式并不会给我留下深刻的印象,但作为您的升级,我假设这只是一个中间状态,之后您将完全删除 PostgreSQL 9.3。您还必须验证 PostGIS 是否 link 与 9.3 库一起使用,否则您可能会遇到一些问题。
我有类似的问题,但解决方法有点不同:
dbname=#\dx
Name | Version | Schema | Description
---------+---------+------------+---------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
postgis | 2.1.5 | postgis | PostGIS geometry, geography, and raster spatial types and functions
dbname=#ALTER EXTENSION postgis UPDATE TO '2.2.0';
dbname=#\dx
Name | Version | Schema | Description
---------+---------+------------+---------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
postgis | 2.2.0 | postgis | PostGIS geometry, geography, and raster spatial types and functions
我遇到了同样的问题。我对 Docker 的解决方案是:
docker exec -i $(docker-compose ps -q postgis) ln -s /usr/lib/postgresql/9.6/lib/postgis-2.3.so /usr/lib/postgresql/9.6/lib/postgis-2.1.so