使用Postgis从Postgres 10升级到11

问题描述 投票:3回答:1

我最近不得不在我的macOS Mojave上使用homebrew从Postgres版本从10升级到11,并且由于需要使用Postgis,在升级Postgres版本后遵循使用brew postgresql-upgrade-database的标准方式看起来并不是那么简单。

我发现this gist看起来很可能解决我的问题。当我尝试在make上运行postgis-2.5.1时,它会抛出一个错误,好像它混淆了Command Line ToolsXcode路径,我目前还没有安装。

下面我粘贴到目前为止我尝试过的命令序列:

❯ xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk

❯ ./configure --with-pgconfig=/usr/local/Cellar/postgresql@10/10.6_1/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.9_2/bin/xml2-config --with-projdir=/usr/local/Cellar/proj/5.2.0 --with-jsondir=/usr/local/Cellar/json-c/0.13.1 --with-pcredir=/usr/local/Cellar/pcre/8.4

❯ make
/usr/local/bin/perl utils/svn_repo_revision.pl
Can't fetch local revision (neither .svn nor .git found)
Not updating existing rev file at 17027
for s in liblwgeom libpgcommon postgis regress raster topology loader utils doc extensions; do \
                echo "---- Making all in ${s}"; \
                /Library/Developer/CommandLineTools/usr/bin/make -C ${s} all || exit 1; \
        done;
---- Making all in liblwgeom
make[1]: Nothing to be done for `all'.
---- Making all in libpgcommon
make[1]: Nothing to be done for `all'.
---- Making all in postgis
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I../liblwgeom -g -O2 -I../libpgcommon  -I/usr/local/Cellar/geos/3.7.1_1/include -I/usr/local/Cellar/proj/5.2.0/include  -I/usr/local/Cellar/libxml2/2.9.9_2/include/libxml2 -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I/usr/local/Cellar/json-c/0.13.1/include -I/usr/local/Cellar/pcre/8.42/include  -fPIC -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I. -I./ -I/usr/local/Cellar/postgresql@10/10.6_1/include/server -I/usr/local/Cellar/postgresql@10/10.6_1/include/internal -I/usr/local/Cellar/icu4c/63.1/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2   -c -o postgis_module.o postgis_module.c
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
In file included from postgis_module.c:26:
In file included from /usr/local/Cellar/postgresql@10/10.6_1/include/server/postgres.h:47:
/usr/local/Cellar/postgresql@10/10.6_1/include/server/c.h:81:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
make[1]: *** [postgis_module.o] Error 1
make: *** [all] Error 1

即使我在sysroot上明确设置./configure路径或在发布CMAKE_OSX_SYSROOT之前设置make它也行不通。

❯ ./configure --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/ --with-pgconfig=/usr/local/Cellar/postgresql@10/10.6_1/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.9_2/bin/xml2-config --with-projdir=/usr/local/Cellar/proj/5.2.0 --with-jsondir=/usr/local/Cellar/json-c/0.13.1 --with-pcredir=/usr/local/Cellar/pcre/8.4

❯ CMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk make
/usr/local/bin/perl utils/svn_repo_revision.pl
Can't fetch local revision (neither .svn nor .git found)
Not updating existing rev file at 17027
for s in liblwgeom libpgcommon postgis regress raster topology loader utils doc extensions; do \
                echo "---- Making all in ${s}"; \
                /Library/Developer/CommandLineTools/usr/bin/make -C ${s} all || exit 1; \
        done;
---- Making all in liblwgeom
make[1]: Nothing to be done for `all'.
---- Making all in libpgcommon
make[1]: Nothing to be done for `all'.
---- Making all in postgis
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I../liblwgeom -g -O2 -I../libpgcommon  -I/usr/local/Cellar/geos/3.7.1_1/include -I/usr/local/Cellar/proj/5.2.0/include  -I/usr/local/Cellar/libxml2/2.9.9_2/include/libxml2 -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I/usr/local/Cellar/json-c/0.13.1/include -I/usr/local/Cellar/pcre/8.42/include  -fPIC -I/usr/local/Cellar/sfcgal/1.3.6/include -DHAVE_SFCGAL -I. -I./ -I/usr/local/Cellar/postgresql@10/10.6_1/include/server -I/usr/local/Cellar/postgresql@10/10.6_1/include/internal -I/usr/local/Cellar/icu4c/63.1/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2   -c -o postgis_module.o postgis_module.c
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
In file included from postgis_module.c:26:
In file included from /usr/local/Cellar/postgresql@10/10.6_1/include/server/postgres.h:47:
/usr/local/Cellar/postgresql@10/10.6_1/include/server/c.h:81:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
make[1]: *** [postgis_module.o] Error 1
make: *** [all] Error 1

为了记录,我已经安装了macOS_SDK_headers_for_macOS_10.14.pkg我发现它可能是必需的herehere

我真的很感激我可能做错的任何线索或提示或任何其他可以解决问题的方法。

谢谢!

xcode postgresql clang homebrew postgis
1个回答
1
投票

经过很多努力,我最终将旧数据库与以下内容一起转储:

pg_dumpall > /tmp/my_databases.sql

然后安装了一个新的Postgres并使用以下方法恢复了新版本的所有数据:

psql -f /tmp/my_databases.sql

我希望将来能帮助别人。

© www.soinside.com 2019 - 2024. All rights reserved.