yum install error – GPG key retrieval failed

本文介绍了一种常见的在使用yum工具安装Oracle软件时遇到的GPG密钥检索失败的问题及其解决方案。错误表现为无法打开或读取指定的GPG密钥文件。解决方法包括从Oracle的公共YUM仓库获取正确的GPG密钥。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

yum install error – GPG key retrieval failed: [Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

wget http://public-yum.oracle.com/public-yum-ol6.repo 

yum install oracle-rdbms-server-11gR2-preinstall

Action: Installing rpm using yum utility

Error: GPG key retrieval failed: [Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

Solution: wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

[root@k8smaster ~]# yum install ntpdate -y 已加载插件:fastestmirror Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误" One of the configured repositories failed (未知), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=<repoid> ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable <repoid> or subscription-manager repos --disable=<repoid> 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: base/7/x86_64
04-02
<think>我们正在解决一个在安装MySQL时遇到的GPG密钥检索失败的错误。错误信息为:"GPG key retrieval failed: [Errno 14] curl#37 - Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022"。根据引用,我们可以知道这个错误通常发生在使用yum安装MySQL时,系统无法找到指定的GPG密钥文件。 根据引用[1]和引用[2]提供的信息,解决方案是手动导入GPG密钥。引用[1]中给出了具体的命令:`rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022`。这个命令会从MySQL的官方仓库下载GPG密钥并导入到RPM数据库中。 另外,引用[3]提到了一种类似错误的解决方法,虽然针对的是不同的密钥文件,但方法类似,即手动导入密钥。 因此,我们可以按照以下步骤解决: 1. 使用curl或wget下载GPG密钥文件(如果系统没有安装curl,可以使用wget,或者直接使用rpm --import从URL导入)。 但是,引用[1]提供的命令已经可以直接从URL导入,所以我们可以直接运行: ```bash sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 ``` 2. 如果上述命令执行成功,则GPG密钥已经被导入到系统中。然后再次尝试安装MySQL应该就不会出现这个错误了。 3. 如果问题仍然存在,可以检查一下密钥文件是否确实被导入。可以使用以下命令列出所有已导入的GPG密钥,查看是否有MySQL的密钥: ```bash rpm -qa gpg-pubkey* ``` 或者更具体地查找MySQL的密钥: ```bash rpm -qa | grep -i mysql ``` 4. 另外,引用[4]和[5]都提到了相同的错误,说明这是一个常见问题。引用[5]中提到了MySQL5.7安装时类似的错误,其解决方法也是一样的。 注意:如果使用的MySQL版本不同,密钥的URL可能略有不同。例如,对于MySQL 5.7,可能需要使用`RPM-GPG-KEY-mysql`(不带年份)。但根据错误信息,我们这里需要的是`RPM-GPG-KEY-mysql-2022`,所以使用上述命令即可。 因此,我们给出如下解决方案: 步骤: 1. 导入GPG密钥: ```bash sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 ``` 2. 再次运行安装命令,应该可以成功。 如果用户是在安装其他软件包时遇到类似的错误(如引用[3]中的EPE密钥),同样可以采用手动导入对应密钥的方法。 如果用户在执行上述步骤后仍然遇到问题,可能需要检查网络连接,确保能够访问`https://repo.mysql.com`,或者检查是否有防火墙或代理设置阻止了下载。 另外,引用[1]还提到了MySQL安装官方文档,如果问题复杂,可以参考官方文档。 根据上述分析,我们给出回答。</think>### 解决 GPG 密钥检索失败错误 (curl#37) 该错误发生在使用 `yum` 安装 MySQL 时,系统无法访问本地的 GPG 密钥文件 `/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022`。以下是完整解决方案: #### 解决方案步骤 1. **手动导入 GPG 密钥** 执行以下命令从 MySQL 官方源获取密钥: ```bash sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 ``` *说明*:此命令会绕过本地文件系统,直接从 MySQL 官网导入密钥[^1][^5]。 2. **验证密钥导入** 检查密钥是否成功导入: ```bash rpm -qa gpg-pubkey* | grep mysql ``` 正常应返回类似:`gpg-pubkey-3a79bd29-xxxxxxxx` 3. **清理缓存并重试安装** ```bash sudo yum clean all sudo yum install mysql-community-server ``` #### 备选方案 如果上述步骤无效: 1. **手动下载密钥文件** ```bash sudo curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 \ https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 ``` 2. **修改仓库配置** 在 MySQL 的 `.repo` 文件中添加: ```ini gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 ``` #### 错误原因分析 - 本地密钥文件丢失或损坏 - 仓库配置指向不存在的本地密钥路径 - 网络问题导致密钥下载失败 > **重要提示**:确保系统时间正确(使用 `date` 检查),错误的时间会导致 GPG 验证失败[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值