一 问题描述:
安装了redhat6.5后,登录系统使用yum update 命令更新系统。提示:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
无法更新的原因是redhat 默认自带的 yum 数据源是需要注册后才能更新。我们如果想不花钱也可以更新,需要替换掉redhat的官方yum数据源,使用国内的免费yum数据源。
二 操作步骤:
0.前提条件
1)要安装Vmware Tools,方便在Linux和Win 7之间的复制粘贴
2)配置Vmare虚拟机的网络适配器为NAT模式,使得在Linux中能访问互联网
1.检查是否安装yum包
查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:
[root@localhost ~]# rpm -qa |grep yum
yum-metadata-parser-1.0-8.fc6
yum-3.0.1-5.el5
yum-rhn-plugin-0.4.3-1.el5
yum-updatesd-3.0.1-5.el5
2 删除redhat自带的yum包
卸载上面显示的所有yum包:
[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)
再用
[root@localhost ~]# rpm -qa |grep yum
[root@localhost ~]#
查看,无信息显示表示已经卸载完成。
3.下载新的yum包。使用Centos6.5的yum包
首先你得先弄清楚自己的系统版本号和系统位数,使用命令 cat /etc/issue && arch 查看,如果是i386或者i686就是32位的,如果是x86_64就是64位的。然后到 http://mirrors.aliyun.com/找对应系统版本号和系统位数的链接执行下载,
1)如果是64位的系统,找到
yum-3.2.29-81.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
python-urlgrabber-3.9.1-11.el6.noarch.rpm
这四个软件包执行下载,依次输入下面命令,下载四个安装包:
wget http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
wget http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
2)如果是32位的系统,找到
yum-3.2.29-81.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.i686.rpm
yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
python-urlgrabber-3.9.1-11.el6.noarch.rpm
这四个软件包执行下载,依次输入下面命令,下载四个安装包:
wget http://mirrors.aliyun.com/centos/6/os/i386/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.aliyun.com/centos/6/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm
wget http://mirrors.aliyun.com/centos/6/os/i386/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
wget http://mirrors.aliyun.com/centos/6/os/i386/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
说明:wget命令从网络上自动下载文件的工具命令,在安装软件时会经常用到
4 安装yum软件包
注意:单个的安装包可能会依赖其它包(例如yum和yum-fastestmirror会相互依赖),所以我们可以把所有这些包放在一起,用一行命令将它们同时安装即可:
如果是64位系统,请执行:
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm python-urlgrabber-3.9.1-11.el6.noarch.rpm --replacefiles
如果是32位的系统,请执行:
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-metadata-parser-1.1.2-16.el6.i686.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm python-urlgrabber-3.9.1-11.el6.noarch.rpm --replacefiles
注意:安装rpm包时出现如下提示信息,conflicts with意为“与...冲突”,解决办法:为rpm添加参数“--replacefiles”
执行yum的安装后,可以执行rpm -qa |grep yum查看是否已经安装,也可以执行yum list命令看该命令是否有效
5.修改配置文件Centos-6.repo,更换yum的数据源,使用阿里云镜像站点的数据源,依次执行以下命令:
cd /etc/yum.repos.d/ 切换到/etc/yum.repos.d目录
wget http://mirrors.aliyun.com/repo/Centos-6.repo 执行wget命令,从网站下载配置文件Centos-6.repo
gedit Centos-6.repo 用gedit文本编辑器编辑该文件,把文件里面的$releasever全部替换为Linux的版本号数字“6”后保存,或者直接把下面的文字拷贝到Centos-6.repo文件中即可(已经修改好,可以先把文字粘贴到win 7的记事本文件,再把文件复制到Linux中,用gedit文本编辑器编辑修改)
# 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-6 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/os/$basearch/
http://mirrors.aliyuncs.com/centos/6/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/6/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/updates/$basearch/
http://mirrors.aliyuncs.com/centos/6/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/6/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/extras/$basearch/
http://mirrors.aliyuncs.com/centos/6/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/6/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/6/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/6/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/6/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/6/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
6.清除原有缓存
执行命令 yum clean all
7 重建缓存,以提高搜索安装软件的速度
执行命令yum makecache
执行后出现提示Metadata Cache Created,说明缓存创建成功
8.更新系统
yum upgrade 视具体环境执行,教学环境可以随便执行
说明:生产环境对软件版本和内核版本要求非常精确,别没事有事随便的进行yum update操作!!!!!!!!!
yum update:升级所有包同时也升级软件和系统内核
yum upgrade:只升级所有包,不升级软件和系统内核
下图是等待yum upgrade命令执行完后的效果,发现升级完成后,Linux系统桌面的背景颜色都发生了变化