本文安装环境是 CentOS7.6。安装版本是 postgresql-11 。推荐关闭SELinux和防火墙打开相应端口。
安装 postgresql-server。postgesql-server 官方安装教程 。
#设置安装源
[root@promote ~]# yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-ppc64le/pgdg-centos11-11-2.noarch.rpm
#安装postgresql11-server
[root@promote ~]# yum install postgresql11-server postgresql11-client postgresql11-libs postgresql11-contrib postgresql11-devel
#初始化数据库
[root@promote ~]# /usr/pgsql-11/bin/postgresql-11-setup initdb
#添加开机启动
[root@promote ~]# systemctl enable postgresql-11
安装 postgis 。参考postgis 官方安装教程Red Hat / Centos / Scientific Linux 选项。
#安装epel-release
[root@promote ~]# yum -y install epel-release
#安装postgis
[root@promote ~]# sudo yum install postgis25_11 postgis25_11-devel postgis25_11-client postgis25_11-debuginfo postgis25_11-utils
#安装ogr_fdw11扩展
[root@promote ~]# yum install ogr_fdw11 ogr_fdw11-debuginfo pgrouting_11 pgrouting_11-debuginfo
#可选添加开机启动
[root@promote ~]# systemctl enable postgresql-11
#启动和查看postgresql-11服务
[root@promote ~]# systemctl start postgresql-11
[root@promote ~]# systemctl status postgresql-11
[root@promote ~]# systemctl list-unit-files | grep postgresql
postgresql-11.service enabled
#查看开机启动
[root@promote ~]# systemctl list-unit-files | grep postgresql
postgresql-11.service enabled
[root@promote ~]#
#查看数据库服务端口开启情况
[root@promote ~]# netstat -ntlp | grep post
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 10592/postmaster
tcp6 0 0 ::1:5432 :::* LISTEN 10592/postmaster
[root@promote ~]#
创建用户,创建数据库gistest,切换用户到postgres,连接和切换数据库,查看postgis版本信息。
[root@promote ~]# su - postgres
#非第一次登录
[root@promote ~]# su - postgres
上一次登录:五 4月 12 16:51:07 CST 2019pts/1 上
-bash-4.2$ psql
psql (11.2)
输入 "help" 来获取帮助信息.
postgres=#
#安装EXTENSION
postgres=# CREATE EXTENSION postgis;
CREATE EXTENSION
postgres=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION
postgres=# CREATE EXTENSION adminpack;
CREATE EXTENSION
postgres=# CREATE EXTENSION postgis_sfcgal;
CREATE EXTENSION
postgres=# CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION
postgres=# CREATE EXTENSION address_standardizer;
CREATE EXTENSION
postgres=# CREATE EXTENSION addre