目前,咱们常见的系统大概就是Windows、Linux和Mac OS了。Windows系统应该是大部分人最先开始接触的系统,毕竟Windows系统使用起来至关方便,只须要点点鼠标,外加会简单的打字,通常看视频、听音乐、上网都是没问题的。追求完美体验的用户可能会更加喜欢Mac OS系统,相比Windows系统而言,Mac OS用户界面更加的华丽,设计很人性化,用户体验会好不少。至于Linux,则主要安装在服务器上,通常人基本不太会接触,可是对于运维、开发人员而言,多是不得不掌握的一种操做系统。node
固然,随着信息技术的发展,全民素质的提升,愈来愈多的人开始了解Linux并尝试去使用Linux,Linux也逐渐进入了你们的视线。像Ubuntu、Debian、CentOS等Linux系统由于有着相似Windows的桌面和相对人性化的设计而在为人所熟知,大部分初学者基本会安装上述系统来体验一下所谓的Linux系统,若是你对Linux系统也有必定的兴趣,能够去看看《Linux就该这么学》这本书,是一本比较好的Linux入门书籍。linux
今天,我在这里向你们介绍一下如何为RedHat7更换yum源。选择RedHat的缘由很简单:一、RedHat的老板是红帽公司(全球最大的开源技术厂商);二、,RedHat是全世界内使用最普遍的Linux系统。三、RedHat系统具备极强的性能与稳定性,而且在全球范围内拥有完善的技术支持。固然,若是你想要享受红帽公司的技术支持,那是要收费的,若是你不用她的技术支持,那稍稍改变一下,就能够无偿使用RedHat系统了,而这个改变就是更换yum源。vim
若是你新安装了RedHat7,登陆系统使用yum update 更新系统时,会获得以下的提示:centos
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.缓存
(换成通俗一点的话,那就是:快来注册,你不注册,就不给你用。)服务器
由于RedHat 默认自带的 yum 源须要注册,才能更新,而咱们想不花钱也能够更新,那只能替换掉RedHat的yum源了,下面就给你们介绍一下若是更换RedHat的yum源。网络
第一步:检查是否安装yum软件包。less
首先,能够用rpm -qa |grep yum 命令来查看RHEL是否安装了yum,若是安装了,就会显示系统安装的那些yum包:运维
[root@linuxprobe ~]# rpm -qa | grep yum性能
yum-utils-1.1.31-24.el7.noarch
yum-langpacks-0.4.2-3.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-rhn-plugin-2.0.1-4.el7.noarch
PackageKit-yum-0.8.9-11.el7.x86_64
yum-3.4.3-118.el7.noarch
第二步: 卸载redhat自带的yum软件包。
[root@linuxprobe ~]# rpm -e yum-3.4.3-118.el7.noarch --nodeps
[root@linuxprobe ~]# rpm -e yum-utils-1.1.31-24.el7.noarch --nodeps
[root@linuxprobe ~]# rpm -e yum-rhn-plugin-2.0.1-4.el7.noarch --nodeps
[root@linuxprobe ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[root@linuxprobe ~]# rpm -e yum-langpacks-0.4.2-3.el7.noarch --nodeps
[root@linuxprobe ~]# rpm -e PackageKit-yum-0.8.9-11.el7.x86_64 --nodeps
卸载完成后,再用命令 rpm -qa |grep yum 查看是否已经卸载完成,若是输入命令后,无信息显示表示已经卸载完成:
[root@ linuxprobe ~]# rpm -qa |grep yum
[root@ linuxprobe ~]#
第三步.下载新的yum软件包。
通常能够进入如下网站上面查看软件包的版本是否升级或者找到本身系统所对应的文件包版本更新;
网易163网络源地址:http://mirrors.163.com/
CentOS网络源地址:http://centos.ustc.edu.cn/centos/
找到本身所须要的版本下载:
[root@Linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-118.el7.centos.noarch.rpm
--2016-01-17 20:43:15-- http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-118.el7.centos.noarch.rpm
Resolving mirrors.163.com (mirrors.163.com)... 123.58.173.185, 123.58.173.186
Connecting to mirrors.163.com (mirrors.163.com)|123.58.173.185|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-01-17 20:43:15 ERROR 404: Not Found. //若是找不到,是安装包更新了,你能够到这个网站http://mirrors.163.com/centos/7/os/x86_64/Packages/复制下载连接,而后再下载下来;
[root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm
[root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-34.el7.noarch.rpm
[root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-34.el7.noarch.rpm
[root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
第四步、安装yum软件包。
注意:单个的安装包可能会依赖其它包(例如yum和yum-fastestmirror会相互依赖),因此咱们能够把全部这些包放在一块儿,用一行命令将它们同时安装便可:
[root@Linuxprobe ~]# rpm -ivh yum-*
warning: yum-3.4.3-132.el7.centos.0.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 20%]
2:yum-plugin-fastestmirror-1.1.31-3 ################################# [ 40%]
3:yum-3.4.3-132.el7.centos.0.1 ################################# [ 60%]
4:yum-updateonboot-1.1.31-34.el7 ################################# [ 80%]
5:yum-utils-1.1.31-34.el7 ################################# [100%]
第五步、新建repo 配置文件。
[root@linuxprobe ~]# vim /etc/yum.repos.d/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
第六步:运行yum makecache命令生成缓存。
[root@linuxprobe ~]# yum clean all
[root@linuxprobe ~]# yum makecache
[root@linuxprobe ~]# yum update
通过上述六个步骤,新的yum源已经安装完成了,咱们能够用yum install 命令来测试安装是否正常:
[root@Linuxprobe ~]# yum -y install lftp
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package lftp.x86_64 0:4.4.8-7.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
lftp x86_64 4.4.8-7.el7 base 750 k
Transaction Summary
================================================================================================
Install 1 Package
………………省略部分安装过程………………
Installed:
lftp.x86_64 0:4.4.8-7.el7
Complete!
到这里,新的yum源已经安装完成了,之后咱们就能够用yum命令来愉快的使用RedHat系统了,而没必要再担忧会出现注册提示没法更新的问题了。