当前位置: 首页 > article >正文

centos7 install postgres-15

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.rpm
 
 
yum 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 psql


psql (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.kler.cn/news/107952.html

相关文章:

  • Navicat for MySQL 视图创建使用方法
  • 毅速丨金属3D打印能替代传统制造吗?
  • C++ 学习系列 -- 标准库常用得 algorithm function
  • 【LeetCode力扣】189 53 轮转数组 | 最大子数组和
  • 【深度学习】吴恩达课程笔记(一)——深度学习概论、神经网络基础
  • ActiveMQ消息中间件简介
  • 前端的简单介绍
  • No authorization token was found
  • webpack 优化
  • 基于华为云 IoT 物联网平台实现家居环境实时监控
  • MySQL总结 (思维导图,常用)
  • Github的2FA验证问题的丝滑解决方案 ||(Verify your two-factor authentication (2FA) settings)
  • vmware17.0|ubuntu22.04.0 解决灰色Vmware Tool 无法重新安装和 无法和win11相互拖拽文件问题
  • 【EI会议征稿】 2024年遥感、测绘与图像处理国际学术会议(RSMIP2024)
  • IT行业变成了夕阳行业
  • 力扣1047删除字符串中的所有相邻重复项(java,栈解法)
  • 若依框架的使用+代码生成功能
  • Capacitor 打包 h5 到 Android 应用,uniapp https http net::ERR_CLEARTEXT_NOT_PERMITTED
  • PyCharm社区版安装
  • nodejs+vue全国公考岗位及报考人数分析
  • 读取Excel的工具类——ExcelKit
  • GLoRE:大型语言模型的逻辑推理能力探究
  • 薛定谔的猫重出江湖?法国初创公司AliceBob研发猫态量子比特
  • Redis(04)| 数据结构-压缩列表
  • 汽车托运放坑小攻略
  • STM32 CAN使用
  • 【QT】信号和槽能自动传递参数
  • J2EE项目部署与发布(Windows版本)->会议OA单体项目Windows部署,spa前后端分离项目Windows部署
  • c++ 小案例:判断质数猜数字用符号填补心形图案
  • ​Vue3响应式原理