我虚拟机安装的系统是RedHat Enterprise Linux 6.4-i686,是32位的。使用yum命令安装软件时候出现以下错误:
This system is not registered to Red Hat Subscription Management.You can use subscription-manager to register.
经过一番研究,得出结论如果使用redhat的yum源是需要注册付费的,作为一名学生和初学者,我不想花钱罗,哈哈,当然有钱另说。总体思路非常简单就是卸载原来所有yum的依赖包,然后配置使用centos的yum源。这里需要注意的是每个人的环境和系统都不一样,解决方法和一些细节都不尽相同,我们需要“随机应变”,不要盲目照搬教程。
1.卸载RedHat原来的自带的yum包
使用命令 rpm -qa|grep yum 能够查看已经安装的yum包。然后使用命令 rpm -qa|grep yum|xargs rpm -e --nodeps 不检查依赖直接删除所有的rpm包。最后再次用 rpm -qa|grep yum 命令查看,发现没有任何显示,则表示卸载成功。
2.下载新的centos的yum包,然后安装
首先你得先弄清楚自己的系统版本号和系统位数,使用命令 cat /etc/issue && arch 查看,如果是i386或者i686就是32位的,如果是x86_64就是64位的。
然后到http://mirrors.kernel.org/centos/ 或者 http://mirrors.163.com/centos/ 找对应系统版本号和系统位数下载,找到yum、yum-plugin-fastestmirror、yum-metadata-parser、python-urlgrabber这四个软件包下载。如果跟我系统一样是RedHat Enterprise Linux 6.4-i686,则可以打开我分享的 https://pan.baidu.com/s/1hr5IBE8下载。
最后使用命令安装
rpm -ivh yum-metadata-parser-1.1.2.16.el6.i686.rpm
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm python-urlgrabber-3.9.1-11.el6.noarch.rpm (把相互依赖的包一起安装)
在安装过程中因为环境不一样可能出现不同的问题。如果是因为缺少依赖包安装失败会出现 error:Failed dependencies:缺失包 is needed by 你安装的包,这种情况下,你需要下载缺失的包,然后一起安装即可。如果是因为你安装的包已经存在但是版本不一样会出现conflicts with的提示,你需要根据提示把原来的包卸载之后再次安装新的包。
3.更换yum源,使用163的源
打开http://mirrors.163.com/.help/centos.html,在里面下载对应版本的repo文件,比如我下载的是CentOS6-Base-163.repo文件,然后把它放到/etc/yum.repos.d/下。还需要打开CentOS6-Base-163.repo文件修改$releasever为版本号6,修改后的文件已分享至https://pan.baidu.com/s/1boYZfqf
已经修改后的文件内容如下:
# 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 - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
4.清除原有缓存
使用命令 yum clean all 清除原来的缓存。
5.重新建立缓存
使用命令 yum makecache 重建缓存。