news 2026/5/7 17:04:16

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/5/5 23:18:26

EmotiVoice开源项目贡献者激励机制探讨

EmotiVoice开源项目贡献者激励机制探讨 在智能语音技术飞速发展的今天&#xff0c;用户早已不再满足于“能说话”的机器。从虚拟主播到游戏NPC&#xff0c;从有声书平台到无障碍辅助系统&#xff0c;人们对语音交互的期待正从“准确”转向“共情”——声音是否自然&#xff1f…

作者头像 李华
网站建设 2026/5/6 4:53:05

ctfshow_web10

和web9中一样的登录界面&#xff0c;但是之前默认的用户名“admin”没有了随便输入账号密码&#xff0c;没有回显尝试使用万能密码 admin or 11&#xff0c;发现SQL错误回显&#xff0c;应该是SQL注入不小心点到取消&#xff0c;竟然触发下载了一个index.phps返回检查源码&…

作者头像 李华
网站建设 2026/5/5 9:44:03

Kotaemon满减活动规则生成:促销玩法设计

Kotaemon满减活动规则生成&#xff1a;促销玩法设计 在电商大促季&#xff0c;运营团队常常面临一个棘手的问题&#xff1a;如何快速制定一套既吸引用户又不损害利润的满减规则&#xff1f;过去&#xff0c;这依赖于少数资深员工的经验判断&#xff0c;耗时长、主观性强&#x…

作者头像 李华
网站建设 2026/5/2 7:29:55

2、深入了解 PowerShell:功能、优势与 2.0 新特性

深入了解 PowerShell:功能、优势与 2.0 新特性 1. 为何选择 PowerShell 多年来,IT 专业人员一直在寻找能够以一致方式自动化和执行任务的方法。从简单的批处理文件到第三方工具,有许多技术可用于完成这些任务。部分 IT 专业人员还学习了开发语言,如 Visual Basic 或 Java…

作者头像 李华
网站建设 2026/4/26 3:31:32

EVE-NG环境中快速搭建多厂商融合实验

推荐阅读&#xff1a; 1、EVE-NG 2TB全网最新最全镜像下载地址&#xff08;保持更新&#xff09;&#xff1a; https://www.emulatedlab.com/thread-939-1-1.html 2、EVE-NG 2025全网最新最全资源大全&#xff08;保持更新&#xff09;&#xff1a; https://www.emulatedlab…

作者头像 李华