Redhat将yum源改为CentOS

来源:互联网 发布:工口动作数据 编辑:程序博客网 时间:2024/05/01 14:48

    Redhat需要注册才可使用其默认的yum源来下载更新软件,所以更好的选择是将yum源改为CentOS。今天尝试了给机器修改yum源,过程有些艰辛,但实际不难,把过程记录一下。

    参考文章:http://blog.chinaunix.net/uid-20940095-id-3275311.html,里面的过程讲的特别详细,但是完全照着做会有版本的问题,参考文章中用到的6.3CentOS已经不提供软件更新了,你可以打开链接http://mirror.centos.org/centos/查看可用版本,我当前能看到的最新的版本是7.1.1503,所以全部下载最新的版本后,安装python-iniparse时,会提示这个安装包需要Python版本为2.6.6以上,所以又找Python最新版本下载安装,但是安装又提示没有C编译器,所以又去下载C编译器,但是又有一系列的相互依赖的安装包需要装,因为还没有yum不能安装同时安装其依赖包,所以只能一个个包去找,到此已卒。最后改成6.6版,安装完成,过程很顺利。其实可以考虑用现在的yum升级完Python后再去换CentOS7。

    记得联网,具体实现过程如下:

1.      删除原有的yum源

rpm -aq | grep yum|xargs rpm -e –nodeps

2.      下载新的安装包

wget http://mirror.centos.org/centos/6.6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpmwget http://mirror.centos.org/centos/6.6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpmwget http://mirror.centos.org/centos/6.6/os/x86_64/Packages/yum-3.2.29-60.el6.centos.noarch.rpmwget http://mirror.centos.org/centos/6.6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm
    你可以直接打开http://mirror.centos.org/centos/,看有哪些版本,查看版本文件夹,里面如果没有相应的文件那么这个版本可能不能用,需要选择更新的版本。os目录之后根据操作系统类型选择x86_64或者i386,就是64位机和32位机的对应选择。

3.      安装yum软件包

    直接在你下载上面四个包的文件夹下执行。

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpmrpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpmrpm -ivh yum-3.2.29-60.el6.centos.noarch.rpmyum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm
4.      更改yum源

    在/etc/yum.repos.d/新建文件centos.repo。这个文件里面是安装包下载更新的url,同样你可以根据你自己的版本来改动里面的内容,这里使用的是网易的更新源,可以直接浏览器查看http://mirrors.163.com/centos/,看你对应的版本的更新源是否存在。网易CentOS镜像可以下载这个配置文件http://mirrors.163.com/.help/centos.html。

    再有baseurl可用的更新源还有http://ftp.sjtu.edu.cn/centos。

#CentOS-Base.repo## Themirror system uses the connecting IP address of the client and the# updatestatus of each mirror to pick mirrors that are updated to and#geographically close to the client.  Youshould use this for CentOS updates# unlessyou are manually picking other mirrors.## If themirrorlist= does not work for you, as a fall back you can try the#remarked out baseurl= line instead.## [base]name=CentOS-6.6- Base - 163.combaseurl=http://mirrors.163.com/centos/6.6/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.6&arch=$basearch&repo=osgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #releasedupdates[updates]name=CentOS-6.6- Updates - 163.combaseurl=http://mirrors.163.com/centos/6.6/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.6&arch=$basearch&repo=updatesgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additionalpackages that may be useful[extras]name=CentOS-6.6- Extras - 163.combaseurl=http://mirrors.163.com/centos/6.6/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.6&arch=$basearch&repo=extrasgpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additionalpackages that extend functionality of existing packages[centosplus]name=CentOS-6.6- Plus - 163.combaseurl=http://mirrors.163.com/centos/6.6/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.6&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #contrib- packages by Centos Users[contrib]name=CentOS-6.6- Contrib - 163.combaseurl=http://mirrors.163.com/centos/6.6/contrib/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6.6&arch=$basearch&repo=contribgpgcheck=1enabled=0gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

5.      清理缓存

yum clean allyummakecache     #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度yum install software_name   #测试新源是否可用

6. 更新系统

yum update -y

附上一个具体的yum的使用说明:http://blog.163.com/agw_slsyn/blog/static/3091511220133171633301/


有任何问题或建议欢迎指出,谢谢!

转载请注明来源,谢谢!


1 0