news 2026/6/23 9:54:14

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/23 4:09:46

AI知识图谱:一张图看懂AI学习全路径

最近写文章&#xff0c;发现自己有一个习惯&#xff1a; 如果没有一个结构化的知识框架&#xff0c;无论是学习还是写作&#xff0c;我都会非常难受。 这算不算强迫症呢&#xff1f;&#xff08;笑&#xff09; 私以为&#xff0c;知识的价值不仅在于“知道”&#xff0c;更在于…

作者头像 李华
网站建设 2026/6/20 15:25:58

Kotaemon命名实体识别模块扩展技巧

Kotaemon命名实体识别模块扩展技巧 在企业级智能对话系统日益复杂的今天&#xff0c;如何让AI真正“听懂”用户的意图&#xff0c;成为决定服务体验的关键。尤其是在金融、医疗、电信等专业领域&#xff0c;用户一句话中可能隐藏着多个关键信息点——比如“我要查一下工单GD202…

作者头像 李华
网站建设 2026/6/23 19:32:42

1.4 从0到1:AIGC产品应用全景深度解析

1.4 从0到1&#xff1a;AIGC产品应用全景深度解析 在前几节中&#xff0c;我们已经了解了AIGC的发展历程、应用模式和产业格局。现在&#xff0c;让我们深入探讨AIGC产品的具体应用场景&#xff0c;看看这项技术是如何在各行各业中落地生根&#xff0c;并创造出巨大价值的。作为…

作者头像 李华
网站建设 2026/6/23 14:21:57

Kotaemon自然语言生成(NLG)模板优化技巧

Kotaemon自然语言生成&#xff08;NLG&#xff09;模板优化技巧 在智能客服、虚拟助手和知识问答系统日益普及的今天&#xff0c;用户不再满足于“能回答”的机器&#xff0c;而是期待一个“答得准、说得清、信得过”的对话伙伴。然而&#xff0c;大语言模型&#xff08;LLM&am…

作者头像 李华
网站建设 2026/6/22 9:29:26

【AI-提效】svn diff 配置 bcompare

问题 svn diff 配置 bcompare&#xff08;20251218&#xff09; 原生svn diff 没有图形化界面不好用&#xff0c;直接配置diff-cmd /…/bcompare不能使用 解决方案 不废话&#xff0c;直接上代码 #!/bin/bash # SVN参数转BCompare可接受格式的包装脚本&#xff08;精简版&…

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

Kotaemon GPU资源占用监测:显存与算力消耗实测

Kotaemon GPU资源占用监测&#xff1a;显存与算力消耗实测 在智能对话系统从“能答”走向“可靠作答”的演进中&#xff0c;检索增强生成&#xff08;RAG&#xff09;技术正成为企业级应用的核心支柱。Kotaemon 作为一款专注于生产级 RAG 智能体构建的开源框架&#xff0c;其模…

作者头像 李华