1.安装geos、proj、gdal、protobuf、protobuf-c、json-c
geos: https://trac.osgeo.org/geos. 3.6.4
proj: https://proj.org/download.html. 6.0.0
gdal: https://gdal.org/download.html. 3.1.4
protobuf: https://github.com/protocolbuffers/protobuf/releases/tag/v3.5.0. 3.5.0
protobuf-c: https://github.com/protobuf-c/protobuf-c/releases/tag/v1.3.1. 1.3.1
json-c: https://github.com/json-c/json-c/releases/tag/json-c-0.13.1-20180305. 0.13.1
geos、proj、dgal安装过程详见:源码安装gdal
protobuf安装:
1、解压:tar -xvf protobuf-3.5.0.tar.gz
2、进入路径:cd protobuf-3.5.0
sh ./autogen.sh
(若存在configure文件,则省略该步)
注:autogen.sh执行时会去下载资源,如果在无网络环境,可以去互联网环境下载资源,修改脚本去执行。vim autogen.sh 。
下载该两个文件后,分别按照脚本解压放到指定的位置,然后注释掉图中圈出的执行脚本后,去执行autogen.sh,执行成功后会生成configure文件。
3、./configure --prefix=/usr/package/protobuf
4、make
如果存在问题,参考
https://blog.csdn.net/zdy7190555/article/details/96873014
5、make install
protobuf-c 安装:
注:需要输出protobuf的pkgconfig的路径export PKG_CONFIG_PATH=/usr/package/protobuf/lib/pkgconfig
其它安装方式均以二进制包的方式安装。安装过程省略。
需要先安装 libxml2-2.8.0.tar.gz
wget ftp://xmlsoft.org/libxml2/libxml2-2.8.0.tar.gz
获取postgis拓展安装包
wget https://download.osgeo.org/postgis/source/postgis-2.5.5.tar.gz
// http://39.105.87.199:81/postgis-2.5.5.tar.gz
tar -xvf postgis-2.5.4.tar.gz
配置安装参数:
// with-pgconfig 为postgresl安装路径下的
./configure --with-pgconfig=/usr/package/pgsql/11/bin/pg_config --with-geosconfig=/usr/package/geos/bin/geos-config --with-projdir=/usr/package/proj --with-gdalconfig=/usr/package/gdal/bin/gdal-config --with-protobufdir=/usr/package/protobufc --with-jsondir=/usr/include/json-c
编译安装:
make && make install
安装完成,需要:
ln -s /usr/package/gdal/lib/* /usr/package/pgsql/11/lib/
ln -s /usr/package/geos/lib/* /usr/package/pgsql/11/lib/
ln -s /usr/package/proj/lib/* /usr/package/pgsql/11/lib/
ln -s /usr/package/protobuf/lib/* /usr/package/pgsql/11/lib/
ln -s /usr/package/protobufc/lib/* /usr/package/pgsql/11/lib/
或者将这些路径配置到环境变量中( /etc/profile 等)中。
PKG_CONFIG_PATH=/usr/package/libxml2/lib/pkgconfig:/usr/package/json-c/lib/pkgconfig:/usr/package/protobuf/lib/pkgconfig
export PKG_CONFIG_PATH
LD_LIBRARY_PATH=/usr/package/pgsql/11/lib:/usr/package/libxml2/lib:/usr/package/protobufc/lib:/usr/package/protobuf/lib:/usr/package/json-c/lib:/usr/package/geos/lib:/usr/package/proj/lib:/usr/package/gdal/lib
export LD_LIBRARY_PATH
PATH=$PATH:$HOME/bin:/usr/package/pgsql/11/bin:/usr/package/libxml2/bin/:/usr/package/protobufc/bin:/usr/package/protobuf/bin:/usr/package/pgpool/bin
export PATH
1)安装扩展:create extension postgis;
2)测试protobuf-c是否生效:执行:
SELECT ST_AsMVT(q, 'test', 4096, 'geom') FROM (SELECT 1 AS c1, ST_AsMVTGeom(ST_GeomFromText('POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))'),ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom) AS q;
3)测试json-c是否生效:
SELECT st_geomfromgeojson('{"type": "Point","coordinates": [104.853515625,34.379712580462204 ]}');
附录:yum 安装postgis
yum -y install epel-release
yum install postgis25_11 postgis25_11-devel postgis25_11-client postgis25_11-debuginfo postgis25_11-utils
--yum install postgresql-libs.x86_64
yum install --skip-broken postgresql*
yum -y install e2fsprogs-devel uuid-devel libuuid-devel
./configure --prefix=/usr/package/pgsql/11 --with-uuid=ossp
cd /usr/package/pgsql/11/contrib/uuid-ossp/
make && make install
postgres=# create extension “uuid-ossp” ;
安装扩展成功以后,就可以通过uuid_generate_v4()或uuid_generate_v1()查询
Root 用户该pg_stat_statements模块提供了跟踪由服务器执行的所有SQL语句的执行统计数据的方法。
cd /usr/package/postgresql-11.6/contrib/pg_stat_statements
make && make install