news 2026/6/15 13:36:07

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/15 8:00:22

大模型入门指南 - Prompt Engineering:小白也能看懂的“提示词工程”全解析

当你说“随便弄杯喝的”&#xff0c;大模型可能端出板蓝根泡咖啡的黑暗料理&#xff1b;但当你精准描述“少冰三分糖的杨枝甘露加脆波波”&#xff0c;它才会秒变资深奶茶师。这背后的本质差异&#xff0c;在于是否用提示词搭建起“人类需求”与“机器语言”的精准翻译通道。就…

作者头像 李华
网站建设 2026/6/15 17:41:29

MATLAB与HFSS联合仿真

一、联合仿真基础架构 1. 系统组成框架 2. 核心接口技术对比 接口方式实现原理适用场景性能指标COM接口通过Windows COM组件直接调用HFSS对象模型参数实时控制、复杂流程延迟<10ms&#xff0c;稳定性高VBS脚本生成VBScript脚本控制HFSS操作批处理任务、简单控制执行速度中…

作者头像 李华
网站建设 2026/6/15 14:38:09

Kotaemon如何避免上下文截断?智能截取策略优化

Kotaemon如何避免上下文截断&#xff1f;智能截取策略优化 在构建现代智能对话系统时&#xff0c;一个看似不起眼却频频“背锅”的问题浮出水面&#xff1a;为什么AI明明看过文档&#xff0c;回答却像没看过一样&#xff1f; 答案往往藏在“上下文长度限制”这道无形的墙背后。…

作者头像 李华
网站建设 2026/6/15 18:54:08

电子护照阅读器:离境退税商店的智能化革命

引言随着全球旅游经济的蓬勃发展&#xff0c;离境退税政策已成为众多旅游大国吸引国际游客的重要手段。在这一流程中&#xff0c;电子护照阅读器作为关键的信息识别设备&#xff0c;通过其高效、准确的证件处理能力&#xff0c;为离境退税行业带来了革命性的变化。本文将深入探…

作者头像 李华
网站建设 2026/6/15 7:38:07

【完整源码+数据集+部署教程】路旁树木种类巡检检测系统源码分享[一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]

一、背景意义 随着城市化进程的加快&#xff0c;城市绿化的重要性日益凸显&#xff0c;树木作为城市生态系统的重要组成部分&#xff0c;承担着改善空气质量、调节气候、提供栖息地等多重功能。然而&#xff0c;城市树木的种类多样性和生长状况直接影响到城市生态环境的健康与…

作者头像 李华