RedHat8安装postgresql15和 postgis3.4.4记录及遇到的问题总结

安装包对照版本参考 UsersWikiPostgreSQLPostGIS -- PostGIS

如果Red Hat系统上有旧版本的PostgreSQL需要卸载

在较新的Red Hat版本,使用dnf包管理器卸载:sudo dnf remove postgresql-server postgresql

旧版本,使用yum包管理器卸载 sudo yum remove postgresql-server postgresql

一、安装postgres

1、postgresql 比较容易,基本按照官网来就行,安装过程中基本没遇到问题,不做详细介绍。

推荐官方教程 https://www.postgresql.org/download/linux/redhat/

2、安装完成后检查PostgreSQL安装情况

find / -name *postg*

find / -name *pgsql*

rpm -qa | grep postgres 确认是否安装指定的安装包

rpm -qal | grep postgres 这个命令可以查看安装文件的位置

chkconfig --list或systemctl list-unit-files 查看所有服务并找到postgre的服务名称

3、查看postgresql是否运行三种方式

ps -ef | grep postgres 查postgres的进程信息

netstat -tpnl | grep 5432 查postgres的端口号5432是否已经打开

service postgresql-15 status 查看服务状态

4、配置远程访问

vim /var/lib/pgsql/15/data/postgresql.conf

#将文件中"#listen_addresses = 'localhost'"修改为

listen_addresses = '*'

vim /var/lib/pgsql/15/data/pg_hba.conf

#在文件中最底部添加以下配置

host all all 0.0.0.0/0 md5

配置远程访问后重启服务生效

systemctl daemon-reload

systemctl restart postgresql-15

5、修改密码, PostgreSQL 安装完成后会自动创建一个名为 postgres 的数据库管理员用户和一个名为 postgres 的操作系统用户,密码随机生成,因此您需要先修改这两个用户的密码,以便后续的使用。

5.1、修改数据库用户 postgres 的密码:

登录 PostgreSQL:

bash 复制代码
sudo -u postgres psql

修改数据库管理员用户的密码:

bash 复制代码
alter user postgres with password '您的密码';

退出数据库:

bash 复制代码
\q

5.2、修改系统用户 postgres 的密码:

删除系统随机生成的密码:

sudo passwd -d postgres

重新设置用户 postgres 的密码:

sudo -u postgres passwd

6、Navicat连接时"authentication method 10 not supported" 报错,升级Navicat Premium 17解决

也可以参考【已解决】authentication method 10 not supported-CSDN博客

二、安装postgis扩展

根据官方教程https://postgis.net/documentation/getting_started/install_red_hat/

https://postgis.net.cn/documentation/getting_started/install_red_hat/

https://postgis.net/docs/postgis_installation.html#idm734

检查安装包 yum list postgis*

错误信息(参考网址 https://qa.1r1g.com/sf/ask/4088375021/)

bash 复制代码
Error: 
 Problem: cannot install the best candidate for the job
  - nothing provides hdf5 needed by postgis34_15-3.4.4-1PGDG.rhel8.x86_64
  - nothing provides xerces-c needed by postgis34_15-3.4.4-1PGDG.rhel8.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

错误:
 问题: 冲突的请求
  - 没有东西可提供 hdf5(postgis34_15-3.4.4-1PGDG.rhel8.x86_64 需要)
  - 没有东西可提供 xerces-c(postgis34_15-3.4.4-1PGDG.rhel8.x86_64 需要)
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用软件包的最佳候选)

rpm有依赖关系,不能自动解决依赖关系。查找rpm包的网站:http://rpmfind.net/ http://pkgs.org解决,如:

1、Red Hat 8.5.0-4或Centeros8下安装postgis3.4报错没有东西可提供 libjson-c.so.4(JSONC_0.14)(64bit)(postgis34_15-3.4.4-1PGDG.rhel8.x86_64 需要)或nothing provides libjson-c.so.4(JSONC_0.14)(64bit)的解决方法,通过在rpmfind.net网站查找解决,在http://rpmfind.net/中搜索"json-c",在搜索结果中找到"json-c-0.13.1-3.el8.x86_64.rpm"

下载后安装即可(参考:https://blog.csdn.net/weixin_45789369/article/details/127111605),安装命令如下:

bash 复制代码
rpm -Uvh json-c-0.13.1-3.el8.x86_64.rpm

bash 复制代码
wget http://rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packages/json-c-0.13.1-3.el8.x86_64.rpm

2、 xerces-c 依赖包未找到在http://pkgs.org查找解决

bash 复制代码
https://pkgs.org/download/xerces-c
https://rhel.pkgs.org/8/epel-x86_64/xerces-c-3.2.5-1.el8.x86_64.rpm.html
https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/x/xerces-c-3.2.5-1.el8.x86_64.rpm

3、hdf5 依赖包未找到

bash 复制代码
https://rhel.pkgs.org/8/epel-x86_64/hdf5-1.10.5-4.el8.x86_64.rpm.html
https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/h/hdf5-1.10.5-4.el8.x86_64.rpm

hdf5依赖包libsz.so.2()(64bit)

bash 复制代码
https://rockylinux.pkgs.org/8/rockylinux-devel-x86_64/libaec-1.0.2-3.el8.x86_64.rpm.html
https://dl.rockylinux.org/pub/rocky/8/Devel/x86_64/os/Packages/l/libaec-1.0.2-3.el8.x86_64.rpm

postgis扩展安装完成后,查看postgis扩展安装信息

bash 复制代码
rpm -qi postgis34_15
#检查 GDAL 是否支持 HDF5
gdalinfo --formats | grep -i hdf5
pg_config --version

通过pgAdmin连接数据库,并添加postgis扩展功能模块(或SQL语句执行

CREATE EXTENSION postgis;)

至此RedHat8安装、配置postgresql15和 postgis3.4.4完成。

postgis安装相关rpm下载地址:

Index of /pub/repos/yum/15/redhat/rhel-8.5-x86_64/

Index of /pub/repos/yum/common/redhat/rhel-8.5-x86_64/

其它参考资料:

PostgreSql与Postgis安装_postgresql和postgis安装-CSDN博客

http://support.supermap.com.cn/DataWarehouse/WebDocHelp/iPortal/iP/iportal_management/structuralData/PostGISinstall.htm

Chapter 2. PostGIS安装

https://postgis.net/docs/manual-3.5/zh_Hans/postgis_installation.html

PostGIS Extension - PostGIS安装 - 《华为 openGauss v5.0.0 使用手册(企业版)》 - 书栈网 · BookStack

Linux(centos)中使用源码安装PostGIS_postgis:linux下通过源码安装postgis-CSDN博客

Centos8.5源码安装postgreSQL数据库及postGIS扩展 - 方大帝的博客 - 博客园

redhat8 nano 保存退出完整步骤

打开或创建文件:

打开终端,输入 nano 文件名.txt 来打开或创建一个文件。

nano ~/.bashrc

编辑文件:

在 nano 编辑器中编辑你的文件。

保存更改:

完成编辑后,按 Ctrl + O 保存你的更改。

退出编辑器:

保存后,按 Ctrl + X 退出 nano 编辑器。如果需要保存更改并退出,直接按 Ctrl + X;如果不想保存更改并直接退出,可以选择在退出时不要保存(通常在退出时会有提示)。

更新环境变量

source ~/.bashrc

export命令显示当前系统定义的所有环境变量

echo $PATH命令输出当前的PATH环境变量的值

相关推荐
倒流时光三十年16 分钟前
PostgreSQL CASE 条件表达式详解
数据库·postgresql
倒流时光三十年1 小时前
PostgreSQL COALESCE 条件表达式函数详解
数据库·postgresql
雁無痕3 小时前
Postgresql启动无监听端口问题的解决
postgresql
倒流时光三十年5 小时前
PostgreSQL NULLIF 条件表达式函数详解
数据库·sql·postgresql
倒流时光三十年8 小时前
PostgreSQL VALUES 列表详解
数据库·postgresql
倒流时光三十年8 小时前
PostgreSQL GREATEST 条件表达式函数详解
服务器·数据库·postgresql
agilearchitect2 天前
asyncpg:专为 asyncio 打造的 PostgreSQL 驱动
数据库·其他·postgresql
IvorySQL2 天前
PostgreSQL 技术日报 (6月10日)|多工具版本更新,PG19 图语法落地
数据库·postgresql
IvorySQL2 天前
PostgreSQL 全球对话:开源链接世界,共建共治共享
数据库·postgresql·开源
IvorySQL2 天前
PostgreSQL 技术日报 (6月11日)|规划器扩展优化,POSETTE 大会倒计时
数据库·postgresql