今天,我在这里向大家介绍一下如何为RedHat7更换yum源。选择RedHat的原因很简单:1、RedHat的老板是红帽公司(全球最大的开源技术厂商);2、,RedHat是全世界内使用最广泛的Linux系统。3、RedHat系统具有极强的性能与稳定性,并且在全球范围内拥有完善的技术支持。当然,如果你想要享受红帽公司的技术支持,那是要收费的,如果你不用她的技术支持,那稍稍改变一下,就可以免费使用RedHat系统了,而这个改变就是更换yum源。
如果你新安装了RedHat7,登录系统使用yum update 更新系统时,会得到如下的提示:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
(换成通俗一点的话,那就是:快来注册,你不注册,就不给你用。)
因为RedHat 默认自带的 yum 源需要注册,才能更新,而我们想不花钱也可以更新,那只能替换掉RedHat的yum源了,下面就给大家介绍一下如果更换RedHat的yum源。
1.检查是否安装yum软件包。
rpm -qa |grep yum | xargs rpm -e --nodeps
yum-3.4.3-132.el7.noarch
yum-langpacks-0.4.2-4.el7.noarch
yum-rhn-plugin-2.0.1-5.el7.noarch
yum-utils-1.1.31-34.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
2.卸载redhat自带的yum软件包。
#包之间可能会有依赖,按顺序执行
rpm -e yum-3.4.3-132.el7.noarch --nodeps
rpm -e yum-utils-1.1.31-34.el7.noarch --nodeps
rpm -e yum-rhn-plugin-2.0.1-5.el7.noarch --nodeps
rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
rpm -e yum-langpacks-0.4.2-4.el7.noarch --nodeps
3.软件包下载
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.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-50.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-50.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo #设置yum源文件
rpm -ivh yum-* --nodeps --force #强制安装软件包
4.安装yum软件包
rpm -ivh yum-* --nodeps --force
5.修改CentOS7-Base-163.repo配置文件
将下载好的CentOS7-Base-163.repo文件放在/etc/yum.repos.d下,将原来的文件删除(或修改名字备份)
vi /etc/yum.repos.d/CentOS7-Base-163.repo
#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
6. 清除缓存
yum clean all
yum makecache #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度
yum install vim* #测试域名是否可用
附加:配置本地yum源
root用户下
1 创建挂载目录
# mkdir -p /mnt/cdrom/
2 挂载光盘
# mount /dev/cdrom /mnt/cdrom/
3 创建local.repo文件
[Server]
name=Server
baseurl=file:///mnt/cdrom/yum_file/
enabled=1
gpgcheck=0
4.同时安装32为和64位安装包,在文件yum.conf加入:multilib_policy=all