Forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Last active
March 5, 2019 16:58
-
-
Save smellman/2e51b1cf449c499ad5deec454a16a7bc to your computer and use it in GitHub Desktop.
Upgrade PostgreSQL 9.6.5 to 10.0 and Postgis 2.3.x to 2.4.x using Homebrew (macOS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | |
brew unlink [email protected] | |
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/[email protected]/9.6.5/lib/ | |
ln -s /usr/local/Cellar/postgis/2.3.2/lib/postgresql/postgis-2.3.so /usr/local/Cellar/[email protected]/9.6.5/lib/ | |
ln -s /usr/local/Cellar/postgis/2.3.2/lib/postgresql/postgis_topology-2.3.so /usr/local/Cellar/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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 [email protected] | |
rm -rf /usr/local/var/postgres96 | |
rm -rf /usr/local/share/postgresql96 | |
# enable auto load | |
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
andmake
commands - but when runningmake
it errors with:I'm at a standstill ... any advice?