Centos7 completely offline installation postgresql12.5 and postgis3.0 plugin tutorial

                                                        Centos7 completely offline installation postgresql12.5 and postgis3.0 plugin tutorial

1. Postgresql12.5 installation package and postgis3.0 plug-in and related dependencies download address:

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

Note on the content of the offline installation package: the file contains the postgresql12.5 installation package, the postgis3.0 installation package, and the required 4 dependencies and 2 json-c dependent rpm packages.

2. Environmental preparation before installation

Local warehouse, the warehouse uses the system to install the ISO file or download the everything ISO file from the official website. After the local warehouse is built, execute the command:

yum install gcc gcc-c++ openssl openssl-devel  readline readline-devel -y

Note that all installations are offline, and they are all source code compilation and installation methods. The operating system uses centos7.2.

Add ordinary user postgres, the new user command is: useradd postgres.

Upload the file downloaded in the first step to the server.

3. Installation of postgresql12.5

Find the file postgresql-12.5.tar.bz2 and decompress it. The decompression command is: tar jxf postgresql-12.5.tar.bz2

Enter the decompressed directory and execute the command: ./configure --prefix=/usr/local/pgsql &&make&&make install

As shown in the figure above, the installation is successful, postgresql is very user-friendly, and a startup script is prepared for operation and maintenance:

 

The source code package comes with a startup script, and the script path is as follows (note that it is a source code package, not the /usr/local/pgsql specified during pre-compilation):

[root@centos7 start-scripts]# pwd
/usr/local/src/postgresql-9.5.24/contrib/start-scripts
[root@centos7 start-scripts]# ll
total 8
-rw-r--r-- 1 1107 1107 1529 Nov 10 06:34 freebsd
-rw-r--r-- 1 1107 1107 3642 Nov 10 06:34 linux
drwxrwxrwx 2 1107 1107   84 Nov 10 06:45 macos
drwxrwxrwx 2 1107 1107   87 Nov 10 06:45 osx

cp /usr/local/src/postgresql-9.5.24/contrib/start-scripts/linux /etc/init.d/pgsql &&chmod +x /etc/init.d/pgsql && chown -Rf /etc/init.d /pgsql #Copy the startup script to the self-startup directory and grant executable permissions, and change the belonging group to postgres user. (The root user can use the service command to start and stop the service only by changing the belonging group).

The variables used in the script should correspond to the environment variable settings one-to-one. The environment variable settings are as follows: vim /etc/profile

PGDATA=/usr/local/pgsql/data
export PGDATA
PGHOME=/usr/local/pgsql
export PGHOME
PATH=$PATH:$PGHOME/bin:$PGDATA
export PATH PGDATA

 

Initialize the pg database

Since the environment variables have been set, initdb can be executed directly. (This step is similar to binary installation), here you need to use a normal user to execute this command, that is, su switch to the normal user postgres.

If you want to re-specify the path you want using the command initdb -d (it should be noted that the target path must be empty, and the postgres user has permission to read and write this path). If the -d parameter is not specified, then the initialization The program will use the database path defined in /etc/profile.

The following figure shows a successful demonstration of initializing the database.

[postgres@centos2 ~]$ initdb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... PRC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /usr/local/pgsql/data -l logfile start

Use the startup script to manage the start, stop and status query of the pg service

service pgsql start |stop |status |restart

[root@centos2 postgresql-12.5]# service pgsql status
pg_ctl: no server running
[root@centos2 postgresql-12.5]# service pgsql start
Starting PostgreSQL: ok
[root@centos2 postgresql-12.5]# ps -ef | grep postgre
postgres  39004      1  0 20:21 ?        00:00:00 /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
postgres  39006  39004  0 20:21 ?        00:00:00 postgres: checkpointer   
postgres  39007  39004  0 20:21 ?        00:00:00 postgres: background writer   
postgres  39008  39004  0 20:21 ?        00:00:00 postgres: walwriter   
postgres  39009  39004  0 20:21 ?        00:00:00 postgres: autovacuum launcher   
postgres  39010  39004  0 20:21 ?        00:00:00 postgres: stats collector   
postgres  39011  39004  0 20:21 ?        00:00:00 postgres: logical replication launcher   
root      39013   1229  0 20:21 pts/0    00:00:00 grep --color=auto postgre

The above picture is a screenshot of the successful start of the service

4. Installation and configuration of high version cmake

 

In this example, I decompressed and renamed it to cmake, the path is /usr/local/cmake, and the environment variable configuration is: vim /etc/profile

CMAKE_HOME=/usr/local/cmake
PATH=$PATH:$CMAKE_HOME/bin
export PATH

5. Rely on the compilation and installation of gdal

tar xf gdal-2.1.3.tar.xz 
    cd gdal-2.1.3/ 
    ./configure --prefix=/usr/local/gdal
    echo $?
     make && make install

It needs to be explained here that the specified path is for the convenience of postgis reference later. If the default is, the environment variable is not easy to configure. 

Screenshot of successful compilation:

6, rely on the compilation and installation of geos

tar jxf geos-3.8.0.tar.bz2
cd geos-3.8.0/src
cmake ../
make && make install

 Screenshot of successful compilation:

7, rely on the compilation and installation of proj4

 tar zxf proj-4.9.3.tar.gz 
 cd proj-4.9.3/
  ./configure 
    make && make install
    echo $?

 Screenshot of successful compilation (there is an executable program proj):

8. Compile and install json-c

Before compiling, you need to install the two rpm packages in the folder. These two rpm packages are strong dependencies of json-c. The installation command is: rpm -ivh *.rpm

The following figure shows the official compilation steps of json-c:

  unzip mirrors-json-c-master.zip 
  cd json-c/
  mkdir build
  cd build/
     cmake ../
     make && make install

9, compile and install postgis

vim /etc/ld.so.conf

/usr/local/lib
/usr/local/lib64
/usr/local/pgsql/lib

Here is a long-winded sentence. The third line refers to the location of the lib library of postgresql. Write it wherever pg is installed. In this example, because pg is installed under /usr/local/pgsql, you must pay attention to writing this way! ! ! ! 

It needs to be effective like /etc/profile, the command is: ldconfig

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH:/usr/local/include/

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-gdalconfig=/usr/local/gdal/bin/gdal-config

make && make install
 

Screenshot of successful pre-compilation:

--------------- Extensions --------------- 
  PostGIS Raster:                     enabled
  PostGIS Topology:                   enabled
  SFCGAL support:                     disabled
  Address Standardizer support:       disabled

 -------- Documentation Generation -------- 
  xsltproc:             /usr/bin/xsltproc
  xsl style sheets:     
  dblatex:              
  convert:              
  mathml2.dtd:          http://www.w3.org/Math/DTD/mathml2/mathml2.dtd

 Screenshot of successful compilation:

for OLD_VERSION in 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.3.10 2.3.11 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 3.0.0alpha4 3.0.0beta1 3.0.0rc1 3.0.0rc2; do \
	ln -fs "${tpl}" /usr/local/pgsql/datadir/extension/postgis_topology--$OLD_VERSION--3.0.0.sql; \
done
/usr/bin/install -c -m 644 .//postgis_topology.control '/usr/local/pgsql/datadir/extension/'
/usr/bin/install -c -m 644  postgis_topology.control sql/postgis_topology--3.0.0.sql sql/postgis_topology--unpackaged--3.0.0.sql  '/usr/local/pgsql/datadir/extension/'
make[2]: Leaving directory `/root/postgis-3.0.0/extensions/postgis_topology'
make[1]: Leaving directory `/root/postgis-3.0.0/extensions'
[root@centos6 postgis-3.0.0]# echo $?
0

Start the postgresql service, enter the command line operation interface, and execute the following command: 

create extension postgis

select * from pg_available_extensions where name like 'postgis%';

The normal state of the plug-in is at least three lines.

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_topology       | 3.0.0           |                   | PostGIS topology spatial types and functions
 postgis_raster         | 3.0.0           |                   | PostGIS raster types and functions
(4 rows)

 

 

 

 

 

Guess you like

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