redhat6.5版本太老了,配置yum源时。官网既不维护,国内的镜像源也没有6.0的内容。找了好久,最后在阿里镜像 https://mirrors.aliyun.com/centos-vault/6.0/os/x86_64/Packages/ 下找到6.0版本。
redhat6.5只有注册交费才能使用yum,只好自己重新配置yum源。安装centos的yum在redhat6.5下可以使用。在此记录下配置过程。方便以后查阅,也希望能帮助你们解决遇到的问题。
# rpm -qa |grep yum //查询本地的yum
# rpm -qa |grep yum|xargs rpm -e --nodeps //不检查依赖直接删除rpm包
# rpm -qa |grep yum //如果无内容则表示卸载完毕
卸载完毕后开始下载yum所需要的rpm。
wget --no-check-certificate https://mirrors.aliyun.com/centos-vault/6.0/os/x86_64/Packages/yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm
wget --no-check-certificate https://mirrors.aliyun.com/centos-vault/6.0/os/x86_64/Packages/yum-3.2.27-14.el6.centos.noarch.rpm
wget --no-check-certificate https://mirrors.aliyun.com/centos-vault/6.0/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
wget --no-check-certificate https://mirrors.aliyun.com/centos-vault/6.0/os/x86_64/Packages/python-urlgrabber-3.9.1-7.el6.noarch.rpm
因为redhat中的互相依赖问题十分可笑令人崩溃。所以下载后一定要同时安装这四个rpm。
rpm -ivh python-urlgrabber-3.9.1-7.el6.noarch.rpm yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm yum-3.2.27-14.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm
安装完yum后,还需要更换yum源,此时使用163的源
# cd /etc/yum.repos.d/
# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
# vi CentOS6-Base-163.repo
编辑文件 ,把文件内的$releaserver 全部替换为版本号 (6),也可以复制以下内容,并保存。
[base]
name=CentOS-$releasever - 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-$releasever - 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-$releasever - 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-$releasever - 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-$releasever - 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
替换后查看 yum -v 版本,会发现还有可能报错。这是因为我现在的项目用到的时python3.7。redhat自带的时2.6。如果有python多版本就有可能会出现问题。
bash: /usr/bin/yum: /usr/bin/python3.7: bad interpreter: No such file or directory
这是因为与python版本不匹配导致。
查看了好多方法,最终解决:查看一下自己的python路径和yum路径。
[root@oracle11g bin]# whereis python
python: /usr/bin/python /usr/bin/python2.6 /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python /usr/local/bin/python2.7-config /usr/local/bin/python2.7 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
[root@oracle11g bin]# whereis yum
yum: /usr/bin/yum /etc/yum.conf /etc/yum /usr/share/man/man8/yum.8.gz
[root@oracle11g bin]# vim /usr/bin/yum
只需要在/usr/bin/yum中把第一行的#!/usr/bin/python改成#!/usr/bin/python2.6 保存就可以了
yum -v 查看版本号
yum clean all 清除缓存
yum makecache 重建缓存
此时又有可能报错:
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
http://mirrors.163.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
这就很明显了,163中的镜像6.0版本已经不能用,内容是空的。此时更新到7就行。至于原因,我也尚不清楚。redhat6.5 可以用centos/7/版本下的内容。
继续上面的步骤:
cd /etc/yum.repos.d
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
vim CentOS6-Base-163.repo
使用全文替换:
:1,$s/$releasever/7
然后,再次执行
yum clean all
yum makecache
yum update
最后,终于解决。奉劝各位,redhat6.5老家伙了,能不用尽量别用。