centos7 install postgres-15

news/2025/2/13 2:05:50/

env centos7

1.更新包,避免安装时出错

yum update

2. PostgreSQL: Linux downloads (Red Hat family)

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql15-server
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15

3. 安装遇到libzstd >= 1.4.0 问题

wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/l/libzstd-1.5.5-1.el7.x86_64.rpm
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/l/llvm5.0-devel-5.0.1-7.el7.x86_64.rpm
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/l/llvm5.0-5.0.1-7.el7.x86_64.rpm
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/l/llvm5.0-libs-5.0.1-7.el7.x86_64.rpmyum install -y ./libzstd-1.5.5-1.el7.x86_64.rpm
yum install -y centos-release-scl-rh llvm5*

4.重新安装:

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql15-server
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15

5.修改监听端口

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

#listen_addresses = 'localhost'         # what IP address(es) to listen on;
listen_addresses = '0.0.0.0'            # what IP address(es) to listen on;

简单监听所有ip

默认仅监听localhost

6.修改访问权限

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

新增:

host    all             all             192.168.1.0/24         password
# METHOD can be "trust", "reject", "md5", "password", "scram-sha-256",
# "gss", "sspi", "ident", "peer", "pam", "ldap", "radius" or "cert".
# Note that "password" sends passwords in clear text; "md5" or
# "scram-sha-256" are preferred since they send encrypted passwords.# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256
host    all             all             192.168.1.0/24         password

pg_hba.conf解决问题:

Connect failed:  no pg_hba.conf entry for host 

7.开放防火墙

firewall-cmd --zone=public --add-port=5432/tcp --permanent
配置生效
firewall-cmd --reload   # 配置立即生效

参考:命令

开放TCP端口
firewall-cmd --zone=public --add-port=80/tcp --permanent   # 开放tcp80端口
firewall-cmd --zone=public --add-port=443/tcp --permanent   # 开放tcp443端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent   # 开放tcp3306端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent   # 开放tcp6379端口开放UDP端口
firewall-cmd --zone=public --add-port=9595/udp --permanent   # 开放udp9595端口关闭TCP端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent  #关闭tcp5672端口
firewall-cmd --zone=public --remove-port=443/tcp --permanent  #关闭tcp443端口
firewall-cmd --zone=public --remove-port=3306/tcp --permanent  #关闭tcp3306端口
firewall-cmd --zone=public --remove-port=6379/tcp --permanent  #关闭tcp6379端口关闭UDP端口
firewall-cmd --zone=public --remove-port=9595/udp--permanent  #关闭udp9595端口配置生效
firewall-cmd --reload   # 配置立即生效查看防火墙所有开放的端口
firewall-cmd --zone=public --list-ports关闭防火墙
如果要开放的端口太多,嫌麻烦,可以关闭防火墙
systemctl stop firewalld.service查看防火墙状态
firewall-cmd --state查看监听的端口
TCP:netstat -ntlp
UDP: netstat -nulp

8.修改postgres密码

# sudo -u postgres psqlpsql (15.4)
Type "help" for help.postgres=# ALTER USER postgres WITH PASSWORD 'xxxxxxxxxxx';
ALTER ROLE

使用修改后的密码登录测试ok

参考:

PostgreSQL 连接问题 FATAL: no pg_hba.conf entry for host_org.postgresql.util.psqlexception: fatal: no pg_hb-CSDN博客

PostgreSQL: Linux downloads (Red Hat family)

centos7.9安装postgresql15报错_vah101的博客-CSDN博客

PostgreSQL 配置文件 postgresql.conf 及 postgresql.auto.conf-CSDN博客

Centos7开放端口及查看端口开放-腾讯云开发者社区-腾讯云 (tencent.com)

如何查看PostgreSQL 的配置文件在哪里 - 简书 (jianshu.com)

PostgreSQL数据库默认用户postgres的密码 - 郑道杰 - 博客园 (cnblogs.com)


http://www.ppmy.cn/news/1182859.html

相关文章

软考 系统架构设计师系列知识点之设计模式(9)

接前一篇文章:软考 系统架构设计师系列知识点之设计模式(8) 所属章节: 老版(第一版)教材 第7章. 设计模式 第2节. 设计模式实例 相关试题 7. 一组对象以定义良好但是复杂的方式进行通信,产生…

软考系列(系统架构师)- 2009年系统架构师软考案例分析考点

试题一 软件架构设计 【问题1】(9分) 软件质量属性是影响软件架构设计的重要因素。请用200字以内的文字列举六种不同的软件质量属性名称并解释其含义。 常见的软件质量属性有多种,例如性能(Performance)、可用性(Ava…

Linux 基本语句_8_C语言_文件控制

为了解决多个进程同时操作一个文件,产生一些情况,通常对文件进行上锁,已解决对共享文件的竞争 对打开文件进行各种操作: int fcentl(int fd, int cmd, .../*arg*/如果cmd与锁操作有关,那么fcentl函数的第三个参数就要…

51单片机定时器

1、1ms函数设置 2、下面代表每1秒执行一次P2_0赋值 二、实现流水灯 key值1,按一下向一个方向,再按一下,向另一个方向 设置独立按键(这个是为了,控制左移还是右移的标志) crol代表循环左移一位 cror代表循…

当生成式AI遇到业务流程管理,大语言模型正在变革BPM

生成式AI对各领域有很大影响,一个方面在于它改变了很多固有业务的工作流。 工作流(Workflow)是业务流程的一种实现方式,一个业务流程往往包含多个工作流范式以及相关的数据、组织和系统。 因此,提及工作流必然离不开业…

解决cloudflare pages部署静态页面发生404错误的问题

cloudflare pages是一个非常方便的部署静态页面的sass工具。 但是很多人部署上去以后,访问服务会报404错误。什么原因? 原因如下图所示: 注意这个Build output directory, 这个是部署的关键! 这个Build output directory目录的…

STM32 Cube配置RS485 Modbus

STM32CUBUMX配置RS485 modbus STM32(从机)亲测可用 STM32开发(六)STM32F103 通信 —— RS485 Modbus通信编程详解

听GPT 讲Rust源代码--library/std(8)

题图来自Why is Rust programming language so popular?[1] File: rust/library/std/src/sys/sgx/abi/reloc.rs 在Rust源代码中,sgx/abi/reloc.rs文件的作用是定义了针对Intel Software Guard Extensions (SGX)的重定位相关结构和函数。 该文件中的Rela 结构定义了…