A-A+
RedHat yum配置
使用RedHat必须先替换yum,因为RedHat的yum不是免费的,常用的办法是替换为CentOS的。
重要的放在前面:注意版本对应,RedHat7就对应CentOS7。
第一步:删除当前yum配置。
- //查看当前yum源
- rpm -qa yum
- //清除yum源
- rpm -qa|grep yum|xargs rpm -e --nodeps
第二步:下载新的rpm包
一共五个:
- 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
可以去阿里云或者163的镜像站去下载,注意版本。可以使用wget命令下载,也可以在其它windows系统上使用浏览器下载,然后使用ftp上传到服务器上。例如:
- wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm
第三步:强制安装
- 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的版本。
备份一下原文件:
- 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”,修改完成后:
- #CentOS-Base.repo
- #
- # The mirror system uses the connecting IP address of the client and the
- # update status of each mirror to pick mirrors that are updated to and
- # geographically close to the client. You should use this for CentOS updates
- # unless you are manually picking other mirrors.
- #
- # If the mirrorlist= does not work for you, as a fall back you can try the
- # remarked out baseurl= line instead.
- #
- #
- [base]
- name=CentOS-$7 - Base - 163.com
- #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
- baseurl=http://mirrors.163.com/centos/7/os/$basearch/
- gpgcheck=1
- gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
- #released updates
- [updates]
- name=CentOS-$7 - Updates - 163.com
- #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
- baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
- gpgcheck=1
- gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
- #additional packages that may be useful
- [extras]
- name=CentOS-$7 - Extras - 163.com
- #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
- baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
- 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 - 163.com
- baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
- gpgcheck=1
- enabled=0
- gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
最后:
- //清理缓存
- yum clean all
- //重新生成缓存
- yum makecache
可以使用yum安装各种软件了。