postgis的扩展包fuzzystrmatch和postgis_tiger_geocoder的安装

                                      postgis的扩展包和postgis_tiger_geocoder的安装

通常,安装好postgis后,我们进入pg数据库,查询插件,显示插件情况是这样的,

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)

可以看到,2,3,4并没有启用,也就是说默认并不启用,那么如何启用它们呢?

postgres=# create extension postgis_tiger_geocoder;
ERROR:  required extension "fuzzystrmatch" is not installed
HINT:  Use CREATE EXTENSION ... CASCADE to install required extensions too.

上图显示,要启用postgis_tiger_geocoder需要先安装fuzzystrmatch。

fuzzystrmatch这个扩展是在postgresql的源码安装包内的contrib目录下,进入fuzzystrmatch的目录,直接make &&make install即可。过程如下图:

[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 $?

 

再次进入pg数据库,执行如下命令就不会报错啦:

postgres=# CREATE EXTENSION fuzzystrmatch; 
CREATE EXTENSION
postgres=# create extension postgis_tiger_geocoder;
CREATE EXTENSION

 

猜你喜欢

转载自blog.csdn.net/alwaysbefine/article/details/114987779