我最近不得不在macOS Mojave上使用homebrew
将Postgres版本从10升级到11,由于需要使用Postgis,遵循标准的{{1 }},然后升级Postgres版本。
我发现this gist似乎可以解决我的问题。当我尝试在brew postgresql-upgrade-database
上运行make
时,抛出一个错误,似乎使postgis-2.5.1
与Command Line Tools
路径混淆了,而我目前尚未安装。
下面,我粘贴到目前为止已经尝试过的命令序列:
Xcode
即使我在发布❯ 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
和here,它们可能是必需的。{p>
我非常感谢我做错事情的任何线索或技巧,或者可以解决问题的其他方法。
谢谢!
答案 0 :(得分:1)
经过大量的努力,我最终将旧数据库与以下内容一起转储:
pg_dumpall > /tmp/my_databases.sql
,然后安装新的Postgres,并使用以下命令将所有数据恢复回新版本:
psql -f /tmp/my_databases.sql
我希望它将来对其他人有帮助。