rhel 7.0 配置centos yum源(2016/12/8),成功!

时间:2021-05-05 06:43:44

1.首先查看redhat 7.0系统本身所安装的那些yum 软件包:

  rpm -qa | grep yum              #列出所有已安装的yum包

2.删除这些包:

  rpm -e *.rpm --nodeps            #删除所有以前的yum包

3.下载新的yum rpm包:(2016/12/8 最新版本rpm,如果404 NOT FOUND错误,自己进去网址,换成最新的rpm包的名字)

  wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.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-34.el7.noarch.rpm

  wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-34.el7.noarch.rpm

  wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm

4.安装下载的rpm包:

  rpm -ivh yum-*

5.配置CentOS-Base.repo:(2016/12/8 最新源网址配置)

  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