A-A+

RedHat yum配置

2018年10月18日 技术 暂无评论 阅读 1,542 次

使用RedHat必须先替换yum,因为RedHat的yum不是免费的,常用的办法是替换为CentOS的。

重要的放在前面:注意版本对应,RedHat7就对应CentOS7。

第一步:删除当前yum配置。

  1. //查看当前yum源
  2. rpm -qa yum
  3. //清除yum源
  4. rpm -qa|grep yum|xargs rpm -e --nodeps

第二步:下载新的rpm包

一共五个:

  1. rpm-4.11.3-25.el7.x86_64.rpm
  2. yum-metadata-parser-1.1.4-10.el7.x86_6
  3. python-urlgrabber-3.10-8.el7.noarch.rpm
  4. yum-3.4.3-154.el7.centos.noarch.rpm
  5. yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm

可以去阿里云或者163的镜像站去下载,注意版本。可以使用wget命令下载,也可以在其它windows系统上使用浏览器下载,然后使用ftp上传到服务器上。例如:

  1. wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm

第三步:强制安装

  1. rpm -ivh --force rpm-4.11.3-25.el7.x86_64.rpm yum-metadata-parser-1.1.4-10.el7.x86_6 python-urlgrabber-3.10-8.el7.noarch.rpm yum-3.4.3-154.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm

第四步:修改配置文件

这步比较重要,尤其要注意CentOS的版本。

备份一下原文件:

  1. mv /etc/yum.repos.d /etc/yum.repos.d.backup

下载对应版本的配置文件:http://mirrors.163.com/.help/centos.html,比如CentOS7的配置文件地址为:http://mirrors.163.com/.help/CentOS7-Base-163.repo。

将下载的.repo文件中的 $releasever 全部修改为目标版本。比如修改为“7”,修改完成后:

  1. #CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client.  You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you, as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12. [base]
  13. name=CentOS-$7 - Base - 163.com
  14. #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
  15. baseurl=http://mirrors.163.com/centos/7/os/$basearch/
  16. gpgcheck=1
  17. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  18. #released updates
  19. [updates]
  20. name=CentOS-$7 - Updates - 163.com
  21. #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
  22. baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
  23. gpgcheck=1
  24. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  25. #additional packages that may be useful
  26. [extras]
  27. name=CentOS-$7 - Extras - 163.com
  28. #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
  29. baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
  30. gpgcheck=1
  31. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  32. #additional packages that extend functionality of existing packages
  33. [centosplus]
  34. name=CentOS-$7 - Plus - 163.com
  35. baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
  36. gpgcheck=1
  37. enabled=0
  38. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

最后

  1. //清理缓存
  2. yum clean all
  3. //重新生成缓存
  4. yum makecache

可以使用yum安装各种软件了。

标签:

给我留言

Copyright © 字痕随行 保留所有权利.   Theme  Ality

用户登录

分享到: