因Redhat 的更新包只对注册的用户生效,so 我们需要将其变更一下才能使用
以下操作本人已实机操作成功。
操作步骤:
1.首先查看redhat 7.0系统本身所安装的哪些yum 软件包:
rpm -qa | grep yum #列出所有已安装的yum包
2.删除这些包:
rpm -e *.rpm --nodeps #删除所有以前的yum包
组合命令:rpm -qa | grep yum |xargs rpm -e --nodeps
命令执行结束后再次执行:rpm -qa | grep yum
没有结果即为删除成功
3.下载新的yum rpm包:(以下为2017-09-07最新版本rpm,如果404 NOT FOUND错误,自己进去网址,换成最新的rpm包的名字)
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-40.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-40.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
4.安装下载的rpm包:
rpm -ivh yum-*
5.配置CentOS-Base.repo:(2017-09-07 最新源网址配置)
vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-7-Base
baseurl=http://mirrors.sohu.com/centos/7/os/x86_64/
gpgcheck=1
#released updates
[updates]
name=CentOS-7- Updates
baseurl=http://mirrors.163.com/centos/7/updates/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#packages used/produced in the build but not released
[addons]
name=CentOS-7- Addons
baseurl=http://mirrors.163.com/centos/7/sclo/x86_64/sclo/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7- Extras
baseurl=http://mirrors.163.com/centos/7/extras/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7- Plus
baseurl=http://mirrors.163.com/centos/7/centosplus/x86_64/
gpgcheck=1
enabled=0
注意一定要顶头编辑
如下图所示
保存退出。
6.yum源配置完成:
yum clean all
7.测试yum是否成功:
yum update python
报错:You have enabled checking of packages via GPG keys. This is a
good thing. However, you do not have any GPG public keys installed. You
need to download the keys for packages you wish to install and install
them. You can do that by running the command.
rpm --import public.gpg.key
.........
经查,是key的错误,解决方法是:
cd /etc/pki/rpm-gpg/
ls #列出所有密钥
导入以 release 结尾的密钥
rpm --import RPM-GPG-KEY-redhat-legacy-release
8.经测试,yum成功:
yum update python #顺利使用yum