一、报错
1.报错内容
执行 yum install -y devtoolset-8-gcc* 报错
[root@hcss-ecs-a901 make-4.3] yum install -y devtoolset-8-gcc*
省略...
transaction summary
======================================================================================================
install 5 packages (+17 dependent packages)total size: 67 m
installed size: 194 m
downloading packages:
warning: /var/cache/yum/x86_64/7/centos-sclo-rh/packages/devtoolset-8-gcc-gdb-plugin-8.3.1-3.2.el7.x86_64.rpm: header v4 rsa/sha1 signature, key id f2ee9d55: nokey
retrieving key from https://mirrors.aliyun.com/centos/rpm-gpg-key-centos-7
the gpg keys listed for the "centos-7 - sclo rh" repository are already installed but they are not correct for this package.
check that the correct key urls are configured for this repository.
failing package is: devtoolset-8-gcc-gdb-plugin-8.3.1-3.2.el7.x86_64
gpg keys are configured as: https://mirrors.aliyun.com/centos/rpm-gpg-key-centos-7
2.原因
gpg密钥不匹配 或者 密钥缺失。
(一般来说,都是 .repo 文件的 gpgkey 设置错误导致的)
3.什么是 gpg 密钥?(ai 解释)
gpg(gnu privacy guard)密钥用于验证软件包的完整性和来源。
具体来说,它可以确保软件包在传输过程中没有被篡改,并且确实是由合法的发布者创建的。
gpg 密钥分为公钥和私钥两部分:
- 公钥:用于验证签名,通常发布给用户和系统。
- 私钥:用于对软件包进行签名,只有发布者拥有。
在使用 yum 安装软件包时,系统会使用 gpg 公钥来验证软件包的签名,以确保软件包的安全性。
二、解决
1.问问gpt
- gpt的意思是,我可能没有在 .repo 文件中设置正确的路径。
- 这是真的。
- 因为,我之前给这个文件设置的路径是 阿里云镜像下 centos-7 相关的 gpgkey
2.改进版本的解决方案
- 咱不单纯听 gpt 的,将 gpgkey 完全换成另一个。
- 小孩子才做选择。
- 我们 两个都保留!
2.1 运行命令:
vi /etc/yum.repos.d/centos-sclo-scl-rh.repo
2.2 替换文件内容如下(请别直接抄,把 gpgkey 的 url 换成你需要的 url)
- 同时保留阿里云 和 centos 官方的 gpgkey,我的文件内容是这样的,请注意观察:
- 不同的 gpgkey,使用 “,” 分隔开
- 改动了内容后,:wq保存离开。
# centos-sclo-rh.repo # # please see http://wiki.centos.org/specialinterestgroup/sclo for more # information [centos-sclo-rh] name=centos-$releasever - sclo rh baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/ gpgcheck=1 enabled=1 gpgkey=https://mirrors.aliyun.com/centos/rpm-gpg-key-centos-7,https://www.centos.org/keys/rpm-gpg-key-centos-sig-sclo
2.3 引入 gpgkey
- 引入的gpgkey,来源于上面的 url,你设置了几个,就引入几个
rpm --import https://mirrors.aliyun.com/centos/rpm-gpg-key-centos-7 rpm --import https://www.centos.org/keys/rpm-gpg-key-centos-sig-sclo
2.4 重新安装(我装我的gcc,你装你的软件去)
yum install -y devtoolset-8-gcc*
三、解决
gcc安装成功了
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论