声明:本文参考了互联网上的几篇文章,对其整理,取长舍短而成。但
配置和源地址都没做测试。所以并不能承诺其有效性。本文旨在给出一个对Fedora core,CentOS,和Rhel的通用参考,
非傻瓜化教程,有些地方
需要变通一下。
(一)、修改文件,加入访问快的源地址:通过有4种修改方法:
1.直接下载已经配置好的上海交大的源配置文件
cd
/etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.save wget http://centos.ustc.edu.cn/CentOS-Base.repo.5 mv CentOS-Base.repo.5 CentOS-Base.repo |
2、修改/etc/yum.repos.d下面的相关文件,可以在*base.repo里修改,把[base],[update] 等选项下的baseurl换成你访问快的源地址。
3、将/etc/yum.repos.d下面原有文件中的[base],[update] 等选项下加入enabled=0这一行,然后新建一个自己的xxx.repo文件。当然此文件中就要设为enabled=1了。
4、直接在/etc/yum.conf中加入相关设置,并删除/etc/yum.repos.d目录或将其改名 (不推荐此种方式)
下载于上海交大的CentOS-Base.repo范例文件,可直接使用:(通用于方式1,2,3)
[base] name=CentOS-5 - Base baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #released updates [update] name=CentOS-5 - Updates baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #packages used/produced in the build but not released [addons] name=CentOS-5 - Addons baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #additional packages that may be useful [extras] name=CentOS-5 - Extras baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-5 - Plus baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #contrib - packages by Centos Users [contrib] name=CentOS-5 - Contrib baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 |
(注:可以将baseurl修改成为你认为更快的镜像的地址,但是
注意每个镜像的文件夹格局不一样,修改时请首先
登陆相应的镜像,查看/repodata/文件夹所在的位置,因为YUM首先查找这个文件夹中的更新信息,然后才能获得软件的更新信息并告知用户。
如上面所讲得例子中, http://ftp.sjtu.edu.cn/centos/5/os/$basearch/就是/repodata/的父目录。更多的国内yum源地址参见本文附录。
如上面所讲得例子中, http://ftp.sjtu.edu.cn/centos/5/os/$basearch/就是/repodata/的父目录。更多的国内yum源地址参见本文附录。
$releasever表示当前的OS版本号,如FC5或centos5那这个字符串都将被服务器解析为5,也可以自己改成5。
$basearch表示你所使用的电脑的架构,如果是PC机(一般个人使用的这种)就会解析为i386。)
$basearch表示你所使用的电脑的架构,如果是PC机(一般个人使用的这种)就会解析为i386。)
(二)、 导入key #rpm --import
http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
运行,测试:#yum update
(三)、附录:一些国内可用的源
http://mirror.vmmatrix.net/ CDN Auto Select
http://dxmirror.vmmatrix.net/ China Telecom
http://cncmirror.vmmatrix.net/ China Netcom
http://dxmirror.vmmatrix.net/ China Telecom
http://cncmirror.vmmatrix.net/ China Netcom
ftp://202.38.97.230/sites/fedora.redhat.com 中国教育总网(速度超快)
ftp://ftp.sjtu.edu.cn/ 上海交通大学(上海交大的源很新,和国外几乎是同步)
ftp://ftp.tsinghua.edu.cn 清华大学
ftp://ftp2.tsinghua.edu.cn/ 清华大学2
ftp://ftp3.tsinghua.edu.cn/ 清华大学3(上海交大的livna没有镜像,只好用清华大学的)
修改[livna]一节的代码如下:
ftp://ftp.sjtu.edu.cn/ 上海交通大学(上海交大的源很新,和国外几乎是同步)
ftp://ftp.tsinghua.edu.cn 清华大学
ftp://ftp2.tsinghua.edu.cn/ 清华大学2
ftp://ftp3.tsinghua.edu.cn/ 清华大学3(上海交大的livna没有镜像,只好用清华大学的)
修改[livna]一节的代码如下:
[livna]
name=livna $releasever - $basearch baseurl= ftp://ftp3.tsinghua.edu.cn/mirror/livna/fedora/$releasever/$basearch/ enabled=1 gpgcheck=1 gpgkey= file:///etc/pki/rpm-gpg/RPM-LIVNA-GPG-KEY http://rpm.livna.org/RPM-LIVNA-GPG-KEY |
其中,RPM-LIVNA-GPG-KEY可以在
ftp://ftp3.tsinghua.edu.cn/mirror/livna
下载,并保存到/etc/pki/rpm-gpg/RPM-LIVNA-GPG-KEY中
另外,由于axelget插件会skip ftp site导致无法正常从ftp3.tsinghua.edu.cn下载,所以建议卸载掉axel plugin,或者在执行yum install的时候,使用
--disableplugin=axelget选项,建议卸载,因为教育网的用户连这两个网站的速度够快的了。
ftp://ftp3.tsinghua.edu.cn/mirror/livna
下载,并保存到/etc/pki/rpm-gpg/RPM-LIVNA-GPG-KEY中
另外,由于axelget插件会skip ftp site导致无法正常从ftp3.tsinghua.edu.cn下载,所以建议卸载掉axel plugin,或者在执行yum install的时候,使用
--disableplugin=axelget选项,建议卸载,因为教育网的用户连这两个网站的速度够快的了。
cd /etc/yum.repos.dmv CentOS-Base.repo CentOS-Base.repo.savewget http://centos.ustc.edu.cn/CentOS-Base.repo.5mv CentOS-Base.repo.5 CentOS-Base.repo
|