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

pg配置国内数据源安装

步骤一:# 备份现有的 yum 源配置文件

sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

步骤二:#配置清华源

sudo tee /etc/yum.repos.d/CentOS-Base.repo << 'EOF' # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # [base] name=CentOS-$releasever - Base baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras gpgcheck=1 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/centosplus/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 EOF

步骤三:清理并重建 yum 缓存

# 清理所有 yum 缓存 sudo yum clean all sudo rm -rf /var/cache/yum # 重建 yum 缓存 sudo yum makecache # 测试 yum 是否正常工作 sudo yum check-update

步骤四:安装 PostgreSQL 15

# 1. 添加 PostgreSQL 官方仓库 sudo tee /etc/yum.repos.d/pgdg.repo << 'EOF' [pgdg15] name=PostgreSQL 15 for RHEL/CentOS 7 - $basearch baseurl=https://download.postgresql.org/pub/repos/yum/15/redhat/rhel-7-$basearch enabled=1 gpgcheck=1 gpgkey=https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-15 EOF # 2. 更新缓存并安装 sudo yum makecache sudo yum install -y postgresql15-server postgresql15-contrib # 如果上面的官方源下载慢,可以使用国内镜像 sudo sed -i 's|https://download.postgresql.org/pub/repos/yum/15/redhat/rhel-7-$basearch|https://mirrors.tuna.tsinghua.edu.cn/postgresql/repos/yum/15/redhat/rhel-7-$basearch|g' /etc/yum.repos.d/pgdg.repo

步骤五:初始化和配置 PostgreSQL

# 1. 初始化数据库 sudo /usr/pgsql-15/bin/postgresql-15-setup initdb # 2. 启动 PostgreSQL 服务 sudo systemctl start postgresql-15 # 3. 设置开机自启 sudo systemctl enable postgresql-15 # 4. 查看服务状态 sudo systemctl status postgresql-15 # 5. 修改 postgres 用户密码 sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'YourNewPassword123';" # 6. 允许远程连接(可选) # 修改配置文件 sudo vi /var/lib/pgsql/15/data/postgresql.conf # 找到 listen_addresses,修改为:listen_addresses = '*' # 修改认证配置 sudo vi /var/lib/pgsql/15/data/pg_hba.conf # 在文件末尾添加: # host all all 0.0.0.0/0 md5 # 7. 重启 PostgreSQL 使配置生效 sudo systemctl restart postgresql-15 # 8. 配置防火墙(如果需要) sudo firewall-cmd --permanent --add-port=5432/tcp sudo firewall-cmd --reload

验证安装

# 检查 PostgreSQL 版本 sudo -u postgres psql --version # 登录 PostgreSQL sudo -u postgres psql # 在 psql 命令行中执行: \conninfo \l # 列出数据库 \q # 退出
http://www.cnnetsun.cn/news/128405.html

相关文章:

  • AI知识图谱:一张图看懂AI学习全路径
  • Kotaemon命名实体识别模块扩展技巧
  • 1.4 从0到1:AIGC产品应用全景深度解析
  • Kotaemon自然语言生成(NLG)模板优化技巧
  • 【AI-提效】svn diff 配置 bcompare
  • Kotaemon GPU资源占用监测:显存与算力消耗实测
  • Kotaemon SEO友好设计:静态内容提取技巧
  • Kotaemon CI/CD集成实践:持续交付智能代理
  • 【完整源码+数据集+部署教程】数码管定位系统源码分享[一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]
  • 文档处理大杀器!NVIDIA开源<1B参数模型,支持表格提取和版式分析,太强了!
  • Kotaemon能否用于保险条款解读?复杂文本简化能力
  • 23、跨平台 Unix 系统管理与自动化工具实践
  • 30、Python 并发编程:线程、进程与调度全解析
  • rt-linux下的“硬实时”的hrtimer通知机制
  • 60、C 编程综合知识解析
  • 3、矩阵、狄拉克符号与经典及量子计算基础
  • 6、量子力学原理:自由度、希尔伯特空间与算子
  • 企业级html+css在线英语阅读分级平台管理系统源码|SpringBoot+Vue+MyBatis架构+MySQL数据库【完整版】
  • 使用gitee快速下载国外文件方案
  • 一块8088单板机,桌面上的技术玩具
  • 数字签名与数字证书
  • 国密算法全家桶:一文认清 SM 系列 “安全卫士”
  • RocketMQ的事务消息是如何实现的?
  • 【实证分析】上市公司产品市场竞争优势-含原始数据及do代码(2002-2022年)
  • 招标平台最难的战斗:在持续变化中保持数据稳定与精准
  • 洋驼帮跨境物流
  • 前后端分离滑雪场管理系统系统|SpringBoot+Vue+MyBatis+MySQL完整源码+部署教程
  • Kotaemon在政务场景下的合规性与安全性设计
  • 两款免费神器一键修复,网络难题轻松搞定!
  • 自动化营销有哪些方式,国内外有哪些自动化营销工具?