Centos8.5源码安装postgreSQL数据库及postGIS扩展

本次安装的各版本如下
postgresql-13.5.tar
geos-3.10.2
gdal-3.4.1
proj-8.2.1
postgis-3.2.1

一、安装postgreSQL

包下载地址

选postgresql-13.5.tar.gz。
使用工具将下载好的包传到服务器。
解压 ,进入解压目录

[root@localhost local]# yum install gcc gcc-c++ readline-devel zlib-devel make
[root@localhost local]# tar -zxvf postgresql-13.5.tar.gz 
[root@localhost local]# cd postgresql-13.5
[root@localhost postgresql-13.5]# ./configure --prefix=/usr/local/pgsql
[root@localhost postgresql-13.5]# make
[root@localhost postgresql-13.5]#
make install
[root@localhost postgresql-13.5]# groupadd postgres
[root@localhost postgresql-13.5]# useradd
-g postgres postgres
[root@localhost postgresql-13.5]#
chown postgres:postgres /usr/local/pgsql/data
[root@localhost postgresql-13.5]#
su - postgres

[postgres@localhost bin]$ .
/initdb -D /usr/local/pgsql/data
[postgres@localhost bin]$ .
/pg_ctl -D /usr/local/pgsql/data -l logfile start
[postgres@localhost bin]$ ./psql

postgres=# ALTER USER postgres WITH PASSWORD 'ABcd_123456';
postgres=#
CREATE DATABASE gis57;
postgres=#
ALTER DATABASE gis57 OWNER TO postgres;
postgres=# \q

配置环境变量

[root@localhost local]# echo 'export PATH=/usr/local/pgsql/bin:$PATH' >> /etc/profile
[root@localhost local]# source /etc/profile
[root@localhost local]# psql --version

创建systemd服务文件

[root@localhost local]# sudo vi /etc/systemd/system/pgsql.service
[Unit]
Description=PostgreSQL database server
After=network.target

[Service]
Type=forking
User=postgres
Group=postgres
ExecStart=/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -s -l /usr/local/pgsql/data/logfile
ExecStop=/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data -s -m fast
ExecReload=/usr/local/pgsql/bin/pg_ctl reload -D /usr/local/pgsql/data -s

[Install]
WantedBy=multi-user.target
[root@localhost local]# sudo systemctl daemon-reload
[root@localhost local]# sudo systemctl start pgsql
[root@localhost local]# sudo systemctl enable pgsql
[root@localhost local]# sudo systemctl status pgsql
[root@localhost local]# sudo firewall-cmd --permanent --add-port=5432/tcp
[root@localhost local]# sudo firewall-cmd --reload

 

二、安装Proj4

包下载地址

解压,进入解压目录

[root@localhost local]# sudo dnf install sqlite sqlite-devel libtiff libtiff-devel curl libcurl-devel
[root@localhost local]# tar -zxvf proj-8.2.1.tar.gz
[root@localhost local]# cd proj-8.2.1
[root@localhost proj-8.2.1]# ./configure --prefix=/usr/local/pgsql/plugin/proj
[root@localhost proj-8.2.1]# make
[root@localhost proj-8.2.1]# make install

三、安装GEOS

包下载地址

解压,进入解压目录

[root@localhost local]# sudo dnf install autoconf cmake
[root@localhost local]# tar -zxvf geos-3.10.2.tar.bz2
[root@localhost local]# cd geos-3.10.2
[root@localhost geos-3.10.2]# autoconf
[root@localhost geos-3.10.2]# ./configure --prefix=/usr/local/postgresql/plugin/geos
[root@localhost geos-3.10.2]# make
[root@localhost geos-3.10.2]# make install

四、安装GDAL

包下载地址

解压,进入解压目录

[root@localhost local]# tar -zxvf gdal-3.4.1.tar.gz
[root@localhost local]# cd gdal-3.4.1
[root@localhost gdal-3.4.1]# ./configure --prefix=/usr/local/postgresql/plugin/gdal --with-proj=/usr/local/pgsql/plugin/proj
[root@localhost gdal-3.4.1]# make
[root@localhost gdal-3.4.1]# make install

五、安装PostGis

posted @ 2024-08-14 14:49  方大帝的博客  阅读(8)  评论(0编辑  收藏  举报