当我们学习Linux系统时,经常会用的发行版本,非redhat,centos莫属了。但是,我们在使用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源。
既然Redhat系统这么麻烦,那我们为什么还要选择他呢?
我们选择RedHat的原因很简单:
- RedHat的老板是红帽公司(全球最大的开源技术厂商);
- RedHat是全世界内使用最广泛的Linux系统。
- RedHat系统具有极强的性能与稳定性,并且在全球范围内拥有完善的技术支持。
当然,如果你想要享受红帽公司的技术支持,那是要收费的,如果你不用她的技术支持,那稍稍改变一下,就可以免费使用RedHat系统了,而这个改变就是更换yum源。
Redhat7 换源
1.进入 /etc/yum.repos.d 下,将之前目录下的文件进行备份(我这里的操作是将文件全部移动到新建的文件夹 back 下)
2.新建 CentOS-Base.repo 文件
vi CentOS-Base.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
如果是 Redhat6.5 换源,就输入以下内容:
# 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-vault-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
http://mirrors.aliyuncs.com/centos-vault/6.10/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-vault-6.10 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
http://mirrors.aliyuncs.com/centos-vault/6.10/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-vault-6.10 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
http://mirrors.aliyuncs.com/centos-vault/6.10/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-vault-6.10 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos-vault/6.10/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-vault-6.10 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
http://mirrors.aliyuncs.com/centos-vault/6.10/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
检查yum是否配置成功
yum clean all
yum makecache
yum update
yum install -y wget # 任意安装一个,检查是否成功