news 2026/6/5 19:42:25

pg配置国内数据源安装

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
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 # 退出
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/5 23:03:16

《C++ 的本质》全系列知识点通关清单

这份清单是为你准备的避坑指南和面试杀手锏。它剔除了基础语法&#xff0c;直击 2025 年 C 工业界最硬核的“灵魂”考点。&#x1f48e; 《C 的本质》全系列知识点通关清单 1. 资源管理与 RAII (RAII is Religion)核心考点&#xff1a; 为什么析构函数绝不能抛出异常&#xff1…

作者头像 李华
网站建设 2026/6/6 3:50:37

C++ 的本质·第9篇 C++23 与 C++26:编译期安全与未来的终极形态

C 的本质第9篇 C23 与 C26&#xff1a;编译期安全与未来的终极形态 &#x1f52e; 核心命题 Reflection、Pattern Matching、Sender/Receiver C 的进化从未停止。C23 在 ABI 稳定性、模块化和标准库的可用性上进一步完善&#xff1b;而下一代 C26 则聚焦于消除元编程中的安全隐…

作者头像 李华
网站建设 2026/6/5 7:20:50

如何通过Kotaemon减少重复性人工回复?

如何通过Kotaemon减少重复性人工回复&#xff1f; 在企业服务一线&#xff0c;客服人员每天可能要面对上百次“年假怎么算”“订单什么时候发货”这类问题。这些问题不难&#xff0c;但高频、重复&#xff0c;不仅消耗人力&#xff0c;还容易因回答不一致引发误解。更麻烦的是&…

作者头像 李华
网站建设 2026/6/5 6:32:59

亚马逊大额采购自养号全攻略:轻松上手无担忧

在当今跨境电商的激烈竞争中&#xff0c;亚马逊大额采购自养号成为许多卖家提升店铺流量、销量和产品评价的重要手段。然而&#xff0c;自养号并非易事&#xff0c;其背后蕴含着诸多复杂的技术原理&#xff0c;需要卖家精心布局&#xff0c;以确保账号的安全性、稳定性和有效性…

作者头像 李华
网站建设 2026/6/6 3:05:07

手写简易Spring(八)

参考小傅哥的教程&#xff1a;第09章&#xff1a;Aware感知容器对象 | 小傅哥 bugstack 虫洞栈 本期的目标是实现Aware功能&#xff0c;Aware是一个顶层接口&#xff0c;其拥有众多子类&#xff0c;如BeanClassLoaderAware、BeanNameAware、BeanFactoryAware、ApplicationCont…

作者头像 李华
网站建设 2026/6/6 12:35:18

Kotaemon + GPU算力加速:释放大模型推理极致性能

Kotaemon GPU算力加速&#xff1a;释放大模型推理极致性能 在企业级智能对话系统日益复杂的今天&#xff0c;一个核心挑战始终摆在开发者面前&#xff1a;如何让大语言模型既“懂行”又“快答”&#xff1f;尤其是在面对专业领域的高频问答场景时&#xff0c;用户不会容忍长达…

作者头像 李华