Linux系统下通过yum工具安装软件,能给我们在系统维护过程中带来了很大的方便。但是,经常yum找不到想要的软件,这或许是就是系统管理员最郁闷的时候。CentOS默认的yum更新源是从CentOS的官方镜像列表获取的,而在具体的使用过程中,系统会根据VPS所在拥有的通讯速率及地区自动检测一个速度较快的更新源并使用此更新源。这就是解释了,为什么同一个CentOS系统,在国内的VPS可以按照的软件,到了国外的VPS却找不到了。下面就以163更新源为例子,告诉大家如何更换yum源码。 一、备份旧的源配置文件 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 二、创建新的更新源 vi /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-$releasever - Base baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 [updates] name=CentOS-$releasever - Updates baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 [addons] name=CentOS-$releasever - Addons baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 [extras] name=CentOS-$releasever - Extras baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 [centosplus] name=CentOS-$releasever - Plus baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 三、升级测试 yum update 四、注意 1.如果能够升级成功,则表示已经更换yum更新源码成功。 2.如果是使用其他的yum,可能需要导入key;这时候找到yum的可以,并导入即可使用如下命令即可:rpm --import http://。 (责任编辑:IT) |