Offline compilation and installation of PostgreSQL 12.5+ PostGIS3.0 + SFCGAL1.3

                                  Offline compilation and installation of PostgreSQL 12.5+ PostGIS3.0 + SFCGAL1.3

             

Related background introduction before installation:

PostgreSQ L is an object-relational database management system (ORDBMS), and it is currently the most powerful, feature-rich and complex free software database system. It originated from the Berkeley (BSD) database research project. It is currently one of the most important open source database product development projects and has a very wide range of users.
PostGIS adds the ability to store and manage spatial data on the object-relational database PostgreSQL, which is equivalent to the spatial part of Oracle. The biggest feature of PostGIS is that it conforms to and implements some specifications of OpenGIS, and is the most famous open source GIS database. As one of the pillars of open source GIS, PostGIS has strong spatial data storage, management, and analysis capabilities.

PostGIS converts the PostgreSQL database management system into a spatial database by adding support for spatial data types, spatial indexes and spatial functions to PostgreSQL. PostGIS is an extension of the object- relational database system PostgreSQL. PostGIS provides the following spatial information service functions: spatial objects, spatial indexes, spatial operation functions and spatial operators. At the same time, PostGIS follows the specifications of OpenGIS. Because PostGIS is built on PostgreSQL, PostGIS automatically inherits important "enterprise-level" features and open source standards. It can be said that PostGIS is just a plug-in for PostgreSQL, but it turns PostgreSQL into a powerful spatial database! PostGIS is a plug-in implemented by a group of foreign GISers in PostgreSQL. PostgreSQL is a well-known old database, which is characterized by full functions and can do anything (as a data warehouse, as a business database, as an MQ, as an MPP, etc.)

The copyright of PostGIS is included in the GNU GPL, which means that anyone can freely obtain the source code of PostGIS and do research and improvement on it. It is precisely because of this that PostGIS has developed rapidly, and more and more enthusiasts and research institutions have participated in the development and improvement of PostGIS applications.

PostGIS was developed by Refractions Research Inc. Refractions is a GIS and database consulting company. Refraction initially studied the implementation of spatial databases on the basis of PostgreSQL. The spatial data types and functions provided by PostgreSQL are far from meeting the needs of GIS. , Research work often falls into a dilemma, the final result is often a lot of manpower and material resources, but the product is extremely complex and low performance. These reasons directly or indirectly contributed to the implementation of the PostGIS project.

Problem description of the installation sequence :

The reasonable order of installing postgigrs should be as follows: postgresql--->(dependency required by postgis)--->postgis--->Enter the postgresql database, select the database to be used and add extension plug-ins to the library, postgresql It is the basic software, so it must be installed first, and the dependency of postgis can be divided into two parts, one is geos library + gdal library + proj library + json-c library. If these four libraries are installed correctly, then You can already compile and install postgis and activate it in the pg database or add a new plug-in, but it should be noted that at this time postgis does not support the analysis, storage, and calculation of 3D data, and only supports 2D geographic information. On the basis of the previous four libraries, four libraries are installed. These four libraries are protobuf+protobuf-c+cgal+sfcgal, where protobuf and protobuf-c are a pair, and the former is a strong dependency of the latter (follow-up You need to be careful when installing), cgal and sfcgal are another pair, and they are also a strong dependency. These four libraries all depend on boost, the basic library.

There is also a network analysis plug-in PgRouting, this plug-in has nothing to do with postgis, and has a dependency on cgal, boost, if necessary, you can install it.

Practical part of installation and deployment:

(1) According to the previous instructions on the installation sequence, the installation tutorial of postgresql + four basic libraries geos library + gdal library + proj library + json-c library is on another blog, please complete according to this blog first , it is not recommended to install postgis at this time . The blog address is:

https://blog.csdn.net/alwaysbefine/article/details/114874242    (Compilation and installation test the patience of people, please install patiently, don’t be afraid of failure)

(2) Compilation and installation of protobuf+protobuf-c+cgal+sfcgal

Need special explanation, the version of protobuf must be at least 2.6.1. There are two versions on GitHub. If you download from there, you need to pay attention to one version without the configure script. You need to download the gtest plug-in online. Basically, you don't want to use it in China. The Internet speed is moving! ! The version I provided has gtest installed.

The four libraries are divided into two pairs, protobuf is installed first, protobuf-c is installed later, cgal is installed first, and sfcgal is installed later. Before installation, yum installs the development libraries that these four libraries depend on. The command is as follows:

yum install -y gcc gcc-c++ libffi-devel python-devel mpfr-devel gmp-devel boost-devel openssl-devel readline-devel libxml2-devel

Pay special attention to libxml2 and boost inside. You can compile and install the source code, or you can use yum to install the development library (if you feel that the difficulty is not high enough, please compile these two things yourself).

Download of installation package :

Link: https://pan.baidu.com/s/12GFnU_kdCJ_4UtJ3F03oXw
Extraction code: 
After copying this content, open the Baidu SkyDrive mobile app after copying this content, and the operation is more convenient---Share from Baidu SkyDrive  Super Member V3

The content description of the installation package: 8 postgis dependencies, postgresql startup script, the environment variable file profile and ld.so.conf to be used during the installation process, the configuration file can be moved to the original directory after changing according to your own installation path Normal use. Comes with a rar installation package,

(The path of the pgsql file is /etc/init.d/ profile The path of the file is /etc/ld.so.conf The path of the file is /etc/, rar After decompressing the installation package, make && make install can use rar And unrar order)

 

1) protobuf installation

cd protobuf-2.6.1
./configure  --prefix=/usr/local/protobuf
make && make install

Note that you must specify the installation path ! ! ! 

2) Installation of protobuf-c

vim /etc/profile add the following at the end of the file:

export PROTOBUF_HOME=/usr/local/protobuf
export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig

 Execute the command source /etc/profile to activate environment variables

After decompressing the installation file, enter the directory and execute compilation:

cd protobuf-c-1.3.1
./configure  --prefix=/usr/local/protobuf-c
make && make install

Note that you must specify the installation path ! ! !  

3) Installation of cgal

cd cgal-releases-CGAL-4.13/
mkdir build
cd build
cmake ../
make &&make install

Note, don't try to specify the installation directory, everything is OK by default ! ! ! !

4) Installation of sfcgal

cd SFCGAL-1.3.6/
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/sfcgalcmake ../
make &&make install

Note that you must specify the installation path ! ! ! 

5) Installation of postgis (exciting moment):

Pre-compilation stage:

./configure --prefix=/usr/local/postgis \
 --with-gdalconfig=/usr/local/gdal/bin/gdal-config \
 --with-pgconfig=/usr/local/pgsql/bin/pg_config  \
 --with-protobufdir=/usr/local/protobuf-c \
 --with-sfcgal=/usr/local/sfcgal/bin/sfcgal-config

 

If it is correct, then make & make install to complete the installation

6) Use of postgis

postgres=# create extension postgis;
CREATE EXTENSION
#安装过了sfcgal,创建扩展测试下
postgres=# create extension postgis_sfcgal;

The installation of the extension is likely to be unsuccessful, because love reported that libprotobuf-c.so.1 was not found. The specific reason is unknown. There are two solutions:

Solution 1. Find this file and link it to the /usr/lib directory. The specific command is: ln -s /usr/local/protobuf-c/lib/libpro/protobuf-c.so.1 /usr/lib/

The method used in this article

Option 2, write the full path of the found file into the /etc/ld.so.conf file, and execute the ldconfig command

The SQL statement can query the status of the plug-in. The specific SQL statement is. You can see that the version number in the third column indicates that the installation is successful:

[postgres@centos2 ~]$ psql
psql (12.5)
Type "help" for help.

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)

 

Guess you like

Origin blog.csdn.net/alwaysbefine/article/details/114971627