无法搜索文件:无法为 repo 'mariadb-main' 下载 gpg 密钥:Curl 错误 (37)

use*_*267 4 yum centos mariadb

我使用此处给出的说明在装有 CentOS 的计算机上安装了 MariaDB:

MariaDB 包存储库设置和使用 - MariaDB 知识库

我使用的基本命令是:

sudo yum install MariaDB-server MariaDB-client  
Run Code Online (Sandbox Code Playgroud)

而且我没有安装 Maxscale 或 percona。

MariaDB 安装已成功完成,但现在如果我在 bash shell 中输入尚未卸载的命令,则会收到此错误:

Failed to search for file: Failed to download gpg key for repo 'mariadb-main': Curl error (37): Couldn't read a file:// file for file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY [Couldn't open file /etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY]
Run Code Online (Sandbox Code Playgroud)

例如,如果我输入命令 ftp,以前我会收到一条消息,指示 ftp 未安装,并且我会得到一些关于我的意思和想要下载的命令的建议。但是,现在我明白了:

[username@localhost ~]$ ftp
bash: ftp: command not found...
Failed to search for file: Failed to download gpg key for repo 'mariadb-main': Curl error (37):     Couldn't read a file:// file for file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY [Couldn't open file   /etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY]
[username@localhost ~]$
Run Code Online (Sandbox Code Playgroud)

经过一番搜索,我发现这是因为文件 etc/yum.repos.d/mariadb.repo 有一个条目:

gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY    
Run Code Online (Sandbox Code Playgroud)

并且在 etc/pki/rpm-gpg 中不存在 MariaDB-Server-GPG-KEY 文件

我想这应该是在我安装 mariadb 时自动创建的?我如何使这个 bash 错误消失?有什么方法可以手动下载或创建此文件?

--- 编辑 ---
解决方法如下:

按照菲利普的回答(https://unix.stackexchange.com/a/602962/28907)中的解释下载了 RPM-GPG-KEY-MariaDB

复制到 /etc/pki/rpm-gpg/

在/etc/yum.repos.d/mariadb.repo将行更改gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY为gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-MariaDB

将 mariadb.repo 文件中其他条目的 gpgcheck 设置为 0(我没有安装 maxscale 和 mariadb 企业版)

Phi*_*ing 5

电信公司的评论回答了这个问题的根本原因:

显然你已经安装了 PackageKit-command-not-found RPM 包。它为 shell 的“未找到命令”错误处理程序添加了一个特殊的定制,它尝试查看命令是否存在于当前未安装的包中,并为这种情况生成信息更丰富的错误消息。

但是要进行检查,您必须让所有配置的包存储库都可以访问——包括它们的 GPG 密钥可用。如果出现问题,标准错误消息将替换为更神秘的消息。

根据Laurentino 的回答,这是为 repo 下载正确的 gpg 密钥mariadb-main并移动到目录的简单问题/etc/pki/rpm-gpg/:

wget https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Run Code Online (Sandbox Code Playgroud)

其他存储库将具有不同的密钥,此处无法合理提供详尽的链接列表。


小智 2

对我来说,解决方案是手动执行

sudo wget https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Run Code Online (Sandbox Code Playgroud)

直接在目录 /etc/pki/rpm-gpg/ 内,并创建文件 RPM-GPG-KEY-MariaDB。