You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS更新/安装时pgdg-common仓库元数据下载失败求助

解决CentOS中软件包更新/安装时的GPG签名验证错误

问题现象

在CentOS Stream 8执行以下更新命令:

cd ~
sudo yum update

返回错误:

Error: Failed to download metadata for repo 'pgdg-common': repomd.xml GPG signature verification error: Bad GPG signature

同时在CentOS 7服务器尝试安装Docker或更新软件包时,也出现相同的GPG签名验证错误。

服务器详细信息(CentOS Stream 8):
执行命令:

cd ~
hostnamectl

输出:

Static hostname: e2e-101-138
Icon name: computer-vm
Chassis: vm
Machine ID: 7bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Boot ID: c0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Virtualization: kvm
Operating System: CentOS Stream 8
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-529.el8.x86_64
Architecture: x86-64

解决方案

方案1:重新导入对应仓库的GPG密钥

GPG签名错误多由密钥过期或未正确导入导致,针对不同仓库处理:

处理pgdg-common仓库(CentOS Stream 8)

  1. 查看并卸载原有PGDG密钥:
# 列出所有已安装的GPG密钥
rpm -qa | grep gpg-pubkey
# 卸载对应的PGDG密钥,替换为实际密钥名称
sudo rpm -e gpg-pubkey-xxxxxx-xxxxxx
  1. 重新导入PGDG官方GPG密钥(根据PostgreSQL版本调整,示例为13):
sudo rpm --import https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-13
  1. 再次执行更新:
sudo yum update

处理Docker仓库(CentOS 7)

  1. 查看并卸载原有Docker密钥:
rpm -qa | grep gpg-pubkey
sudo rpm -e gpg-pubkey-xxxxxx-xxxxxx
  1. 重新导入Docker官方GPG密钥:
sudo rpm --import https://download.docker.com/linux/centos/gpg
  1. 尝试安装Docker或更新软件包:
# 安装Docker
sudo yum install docker-ce docker-ce-cli containerd.io
# 或执行更新
sudo yum update

方案2:临时跳过GPG验证(应急用,不推荐)

若需要紧急操作,可临时跳过签名验证,但存在安全风险:

sudo yum update --nogpgcheck

也可修改仓库配置文件,关闭GPG检查:

# 编辑pgdg-common仓库配置
sudo vi /etc/yum.repos.d/pgdg-common.repo
# 将gpgcheck=1改为gpgcheck=0,保存后退出

方案3:检查仓库配置正确性

确保仓库配置文件中的baseurl和gpgkey路径有效,以pgdg-common为例:

[pgdg-common]
name=PostgreSQL common RPMs for RHEL / Rocky $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-$releasever-$basearch
gpgcheck=1
gpgkey=https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG
enabled=1

修正错误路径后,重新导入密钥并执行更新。

内容的提问来源于stack exchange,提问作者axy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 17:10:08