news 2026/4/18 4:28:31

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/4/3 3:15:44

Kotaemon广告语创意工厂:品牌传播新利器

Kotaemon广告语创意工厂&#xff1a;品牌传播新利器 在快节奏的数字营销时代&#xff0c;一条出色的广告语可能就是品牌破圈的关键。然而&#xff0c;创意团队常常面临这样的困境&#xff1a;灵感枯竭、反复修改却难以跳出固有框架、新文案总是不自觉地偏离品牌调性——更别提还…

作者头像 李华
网站建设 2026/4/12 12:40:06

Word系列:如何让Word表格中的图片自适应表格尺寸

问题描述 在使用word表格过程中&#xff0c;插入图片的时候&#xff0c;表格会因图片的大小而变动&#xff0c;需要再次调整图片的大小&#xff0c;反复操作很费时间。 解决办法 选择表格&#xff0c;右键表格属性 点击选项 取消勾选【自动重调尺寸以适应内容】 再次插入图…

作者头像 李华
网站建设 2026/4/17 18:41:20

京东商品列表数据API,Python请求示例

一、摘要 京东商品搜索API是京东开放平台提供的重要接口&#xff0c;允许开发者通过关键词搜索获取京东平台上的商品列表信息。该接口为电商应用开发、价格监控、市场分析等场景提供了数据支持。二、接口概述 1.接口基本信息 接口名称‌&#xff1a;京东商品搜索API。 接口功能…

作者头像 李华
网站建设 2026/4/17 2:15:16

Kotaemon如何应对长上下文挑战?内部机制曝光

Kotaemon如何应对长上下文挑战&#xff1f;内部机制曝光 在企业级智能对话系统开发中&#xff0c;一个长期存在的痛点是&#xff1a;随着对话轮次增加&#xff0c;模型要么“忘记”早期关键信息&#xff0c;要么因上下文过载导致性能下降甚至崩溃。用户问&#xff1a;“我之前说…

作者头像 李华
网站建设 2026/4/16 21:42:52

Kotaemon网页抓取插件:构建动态知识库

Kotaemon网页抓取插件&#xff1a;构建动态知识库 在企业智能化转型的浪潮中&#xff0c;一个现实而棘手的问题始终存在&#xff1a;如何让AI系统回答“最新”的问题&#xff1f; 比如&#xff0c;客户问&#xff1a;“我们公司最新的隐私政策有什么变化&#xff1f;” 如果依赖…

作者头像 李华