linux离线安装PostgreSQL12.4及PostGIS30

it2023-03-20  82

1、先通过yum安装PostgreSQL12.4及PostGIS30_12

在postgresql官网找到安装命令,根据提示完成安装

https://www.postgresql.org/download/linux/redhat/ 在postgis官网:http://postgis.net/install/ 根据提示安装postgis yum -y install epel-release yum -y install postgis30_12

安装完成后查看安装日志/var/log/yum.log,如下

2、根据日志下载对应版本的rpm包,如下:

Installed: postgresql12-contrib-12.4-1PGDG.rhel7.x86_64 Installed: postgresql12-libs-12.4-1PGDG.rhel7.x86_64 Installed: postgresql12-12.4-1PGDG.rhel7.x86_64 Installed: postgresql12-server-12.4-1PGDG.rhel7.x86_64 Installed: pgdg-redhat-repo-42.0-11.noarch Installed: sqlite33-libs-3.30.1-1.rhel7.x86_64 Installed: geos38-3.8.1-2.rhel7.x86_64 Installed: xerces-c-3.1.1-10.el7_7.x86_64 Installed: libquadmath-4.8.5-39.el7.x86_64 Installed: libgfortran-4.8.5-39.el7.x86_64 Installed: sqlite33-3.30.1-1.rhel7.x86_64 Installed: proj71-7.1.0-1.rhel7.x86_64 Installed: libgeotiff16-1.6.0-1.rhel7.x86_64 Installed: postgresql12-contrib-12.4-1PGDG.rhel7.x86_64 Installed: libdap-3.13.1-2.el7.x86_64 Installed: cfitsio-3.370-10.el7.x86_64 Installed: protobuf-c-1.0.2-3.el7.x86_64 Installed: CharLS-1.0-5.el7.x86_64 Installed: ogdi41-4.1.0-2.rhel7.x86_64 Installed: boost-serialization-1.53.0-28.el7.x86_64 Installed: libaec-1.0.4-1.el7.x86_64 Installed: hdf5-1.8.12-11.el7.x86_64 Installed: netcdf-4.3.3.1-5.el7.x86_64 Installed: libzstd-1.4.5-3.el7.x86_64 Installed: mesa-libGLU-9.0.0-4.el7.x86_64 Installed: CGAL-4.7-1.rhel7.1.x86_64 Installed: SFCGAL-libs-1.3.1-2.rhel7.x86_64 Installed: SFCGAL-1.3.1-2.rhel7.x86_64 Installed: unixODBC-2.3.1-14.el7.x86_64 Installed: libgta-1.0.4-1.el7.x86_64 Installed: freexl-1.0.6-1.el7.x86_64 Installed: gdal31-libs-3.1.2-1.rhel7.x86_64 Installed: postgis30_12-3.0.2-1.rhel7.x86_64 Updated: glibc-2.17-307.el7.1.x86_64 Updated: glibc-common-2.17-307.el7.1.x86_64 Installed: cpp-4.8.5-39.el7.x86_64 Installed: kernel-headers-3.10.0-1127.19.1.el7.x86_64 Installed: glibc-headers-2.17-307.el7.1.x86_64 Installed: glibc-devel-2.17-307.el7.1.x86_64 Installed: gcc-4.8.5-39.el7.x86_64 Installed: ncurses-devel-5.9-14.20130511.el7_4.x86_64 Installed: readline-devel-6.2-11.el7.x86_64 Installed: zlib-devel-1.2.7-18.el7.x86_64 Installed: libstdc++-devel-4.8.5-39.el7.x86_64 Installed: gcc-c++-4.8.5-39.el7.x86_64 Updated: pgdg-redhat-repo-42.0-12.noarch Updated: pgdg-redhat-repo-42.0-14.noarch Installed: postgresql12-libs-12.4-1PGDG.rhel7.x86_64 Installed: postgresql12-12.4-1PGDG.rhel7.x86_64 Installed: postgresql12-server-12.4-1PGDG.rhel7.x86_64 Installed: gdal31-libs-3.1.3-2.rhel7.x86_64 Installed: postgis30_12-3.0.2-2.rhel7.x86_64

前4个rpm包为postgresql12,剩下的是postgis30_12的插件包

3、将postgresql12相关的4个rpm包上传到指定文件夹中,使用命令全部安装rpm -ivh *.rpm --nodeps --force

4、初始化及配置

初始化数据库 $ /usr/pgsql-12/bin/postgresql-12-setup initdb 配置开机启动 $ systemctl enable postgresql-12 启动服务 $ systemctl start postgresql-12 重启服务 $ systemctl restart postgresql-12 停止服务 $ systemctl stop postgresql-12 修改密码 $ su - postgres psql alter user postgres with password ‘postgres’; 退出 \q 查看安装版本 psql -V 开放端口 $ firewall-cmd --add-port=5432/tcp --permanent $ firewall-cmd --reload 编辑配置文件 $ vi /var/lib/pgsql/12/data/postgresql.conf 修改listen_addresses = ‘*’和port = 5432 $ vi /var/lib/pgsql/12/data/pg_hba.conf 在ipv4下添加host all all 0.0.0.0/0 md5

5、安装PostGIS30_12

同样将所有rpm包上传至指定文件夹中,使用命令rpm -ivh *.rpm --nodeps --force安装 查看安装信息 rpm -qi postgis30_12 启动服务,创建扩展 sudo su - postgres psql 创建扩展 postgres=# CREATE EXTENSION postgis; CREATE EXTENSION 查看扩展 postgres=# SELECT PostGIS_version(); postgis_version

注意:如果使用firewall-cmd --state报错ModuleNotFoundError: No module named 'gi',需按如下进行设置:vim /usr/bin/firewall-cmd, 将#!/usr/bin/python -Es 改为 #!/usr/bin/python2 -Es。

安装包:

链接:https://pan.baidu.com/s/13KvBGAO-LOQc_NimpbBBjQ 提取码:hlbp 复制这段内容后打开百度网盘手机App,操作更方便哦

最新回复(0)