Installation of postgis extension package and postgis_tiger_geocoder
Usually, after installing postgis, we enter the pg database, query the plug-in, and display the plug-in situation like this,
postgres=# select * from pg_available_extensions where name like 'postgis%';
name | default_version | installed_version | comment
------------------------+-----------------+-------------------+---------------------------------------------------------------------
postgis | 3.0.0 | 3.0.0 | PostGIS geometry, geography, and raster spatial types and functions
postgis_tiger_geocoder | 3.0.0 | | PostGIS tiger geocoder and reverse geocoder
postgis_raster | 3.0.0 | | PostGIS raster types and functions
postgis_topology | 3.0.0 | | PostGIS topology spatial types and functions
postgis_sfcgal | 3.0.0 | 3.0.0 | PostGIS SFCGAL functions
(5 rows)
As you can see, 2, 3, and 4 are not enabled, which means they are not enabled by default, so how to enable them?
postgres=# create extension postgis_tiger_geocoder;
ERROR: required extension "fuzzystrmatch" is not installed
HINT: Use CREATE EXTENSION ... CASCADE to install required extensions too.
The figure above shows that to enable postgis_tiger_geocoder you need to install fuzzystrmatch first.
The fuzzystrmatch extension is in the contrib directory in the postgresql source installation package, enter the fuzzystrmatch directory, and just make &&make install. The process is as follows:
[root@centos2 fuzzystrmatch]# make
make -C ../../src/backend generated-headers
make[1]: Entering directory `/root/postgre12.5/postgresql-12.5/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory `/root/postgre12.5/postgresql-12.5/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgre12.5/postgresql-12.5/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory `/root/postgre12.5/postgresql-12.5/src/backend/utils'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgre12.5/postgresql-12.5/src/backend/utils'
make[1]: Leaving directory `/root/postgre12.5/postgresql-12.5/src/backend'
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I../../src/include -D_GNU_SOURCE -c -o fuzzystrmatch.o fuzzystrmatch.c
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I. -I. -I../../src/include -D_GNU_SOURCE -c -o dmetaphone.o dmetaphone.c
gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -shared -o fuzzystrmatch.so fuzzystrmatch.o dmetaphone.o -L../../src/port -L../../src/common -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags
[root@centos2 fuzzystrmatch]# echo $?
0
[root@centos2 fuzzystrmatch]# make install
make -C ../../src/backend generated-headers
make[1]: Entering directory `/root/postgre12.5/postgresql-12.5/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory `/root/postgre12.5/postgresql-12.5/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgre12.5/postgresql-12.5/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory `/root/postgre12.5/postgresql-12.5/src/backend/utils'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be done for `generated-header-symlinks'.
make[2]: Leaving directory `/root/postgre12.5/postgresql-12.5/src/backend/utils'
make[1]: Leaving directory `/root/postgre12.5/postgresql-12.5/src/backend'
/usr/bin/mkdir -p '/usr/local/pgsql/lib'
/usr/bin/mkdir -p '/usr/local/pgsql/share/extension'
/usr/bin/mkdir -p '/usr/local/pgsql/share/extension'
/usr/bin/install -c -m 755 fuzzystrmatch.so '/usr/local/pgsql/lib/fuzzystrmatch.so'
/usr/bin/install -c -m 644 ./fuzzystrmatch.control '/usr/local/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./fuzzystrmatch--1.1.sql ./fuzzystrmatch--1.0--1.1.sql ./fuzzystrmatch--unpackaged--1.0.sql '/usr/local/pgsql/share/extension/'
[root@centos2 fuzzystrmatch]# echo $?
Enter the pg database again, and execute the following commands without error:
postgres=# CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION
postgres=# create extension postgis_tiger_geocoder;
CREATE EXTENSION