-
-
Save smellman/2e51b1cf449c499ad5deec454a16a7bc to your computer and use it in GitHub Desktop.
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work. | |
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0." | |
Database files have to be updated before starting the server, here are the steps that had to be followed: | |
# first stop force reload by launchctl | |
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default | |
brew unlink postgresql | |
brew install postgresql@9.6 | |
brew unlink postgresql@9.6 | |
brew link postgresql | |
# copy postgis 2.3.x to postgresql 9.6 | |
ln -s /usr/local/Cellar/postgis/2.3.2/lib/postgresql/rtpostgis-2.3.so /usr/local/Cellar/postgresql@9.6/9.6.5/lib/ | |
ln -s /usr/local/Cellar/postgis/2.3.2/lib/postgresql/postgis-2.3.so /usr/local/Cellar/postgresql@9.6/9.6.5/lib/ | |
ln -s /usr/local/Cellar/postgis/2.3.2/lib/postgresql/postgis_topology-2.3.so /usr/local/Cellar/postgresql@9.6/9.6.5/lib/ | |
# install postgis 2.4.x to postgresql 9.6 | |
tar zxf ~/Downloads/postgis-2.4.1.tar.gz | |
cd postgis-2.4.1 | |
./configure --with-pgconfig=/usr/local/Cellar/postgresql@9.6/9.6.5/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.6/bin/xml2-config | |
make | |
make install | |
# move 9.6.x db files to another directory | |
mv /usr/local/var/postgres /usr/local/var/postgres96 | |
# start postgresql 9.6 | |
/usr/local/Cellar/postgresql@9.6/9.6.5/bin/pg_ctl start -D /usr/local/var/postgres96 | |
# update postgis 2.3 to 2.4 | |
psql your-database | |
=# alter extension postgis update; | |
# stop postgresql 9.6 | |
/usr/local/Cellar/postgresql@9.6/9.6.5/bin/pg_ctl stop -D /usr/local/var/postgres96 | |
# init new database using 10.0 | |
initdb /usr/local/var/postgres -E utf8 | |
# make timezone and timezonesets directories available for 9.6.x installation | |
mkdir /usr/local/share/postgresql96 | |
cp -r /usr/local/share/postgresql/timezone /usr/local/share/postgresql96 | |
cp -r /usr/local/share/postgresql/timezonesets /usr/local/share/postgresql96 | |
# install postgis 2.3.x to postgresql 10 | |
tar zxf ~/Downloads/postgis-2.3.4.tar.gz | |
cd postgis-2.3.4 | |
./configure --with-pgconfig=/usr/local/Cellar/postgresql/10.0/bin/pg_config --with-xml2config=/usr/local/Cellar/libxml2/2.9.6/bin/xml2-config | |
make | |
make install | |
# finally the actual upgrade | |
# -b is the old binary dir, -B is the new binary dir | |
# -d is the old data dir, -D is the new data dir | |
pg_upgrade -b /usr/local/Cellar/postgresql@9.6/9.6.5/bin -B /usr/local/Cellar/postgresql/10.0/bin -d /usr/local/var/postgres96 -D /usr/local/var/postgres | |
# start 10.0 to check that upgrade works | |
pg_ctl start -D /usr/local/var/postgres | |
# cleanup if upgrade was successful | |
brew uninstall postgresql@9.6 | |
rm -rf /usr/local/var/postgres96 | |
rm -rf /usr/local/share/postgresql96 | |
# enable auto load | |
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist |
@smellman your gist looks like the solution for my quest to upgrade from Postgres 10 to 11. I am having a hard time with make
right after the ./configure
command which returns:
❯ 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
Please notice that clang
command tries to use Xcode path even if I only have Command Line Tools and it is up to date.
I've also already installed macOS_SDK_headers_for_macOS_10.14.pkg
which in many places say that is required for Mojave.
I'd highly appreciate any insights you may have.
Keep rocking!
I'm trying to go from postgresql@10 to 11 with brew postgresql-update-database
and it is failing with the error:
pg_dump: [archiver (db)] query failed: ERROR: could not access file "$libdir/postgis-2.5": No such file or directory
I've got postgis installed and updated (via brew install postgis
) - and I'm not sure where to go next.
I've tried manually installing postgis-2.5.1
against postgresql-11.2 using the ./configure
and make
commands - but when running make
it errors with:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [postgis-2.5.so] Error 1
make: *** [all] Error 1
I'm at a standstill ... any advice?
memo for 10 to 11
postgis configure
if you get following error message
you need set locale option in initdb command