星外飞客

对在中国的CentOS支持者们,一件好事情:CentOS终于有了在中国的镜像,分别设在上海、香港、福建。

活用这个资源的之一,就是通过yum高速更新系统。

在初始环境设置中,我们可以将yum作为一项常驻的服务自动更新系统,但默认的服务器是官方的站点,离中国用户比较远,速度不堪忍受。但修改yum相应配置文件就可以达到高速更新系统的目的,方法如下:

修改/etc/yum.repos.d/CentOS-Base.repo,将镜象站点地址改为在中国的景象站点地址。如下4个为国内镜像:
http://mirror.vmmatrix.net/CentOS/$releasever/os/$basearch/
http://mirror.be10.com/centos/$releasever/os/$basearch/
http://centos.hostlink.com.hk/$releasever/os/$basearch/
http://ftp.hostrino.com/pub/centos/
具体修改内容如下
CODE:

 

C#代码
  1. # CentOS-Base.repo  
  2. #  
  3. # This file uses a new mirrorlist system developed by Lance Davis for CentOS.  
  4. # The mirror system uses the connecting IP address of the client and the  
  5. # update status of each mirror to pick mirrors that are updated to and  
  6. # geographically close to the client. You should use this for CentOS updates  
  7. # unless you are manually picking other mirrors.  
  8. #  
  9. # If the mirrorlist= does not work for you, as a fall back you can try the  
  10. # remarked out baseurl= line instead.  
  11. #  
  12. #   
  13.   
  14. [base]   
  15. name=CentOS-$releasever - Base   
  16. baseurl=http://mirror.vmmatrix.net/CentOS/$releasever/os/$basearch/   
  17. http://mirror.be10.com/centos/$releasever/os/$basearch/   
  18. http://centos.hostlink.com.hk/$releasever/os/$basearch/   
  19. http://ftp.hostrino.com/pub/centos/   
  20. gpgcheck=1   
  21. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4  
  22.  
  23. #released updates   
  24. [update]   
  25. name=CentOS-$releasever - Updates   
  26. baseurl=http://mirror.vmmatrix.net/CentOS/$releasever/os/$basearch/   
  27. http://mirror.be10.com/centos/$releasever/os/$basearch/   
  28. http://centos.hostlink.com.hk/$releasever/os/$basearch/   
  29. http://ftp.hostrino.com/pub/centos/   
  30. gpgcheck=1   
  31. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4  
  32.  
  33. #packages used/produced in the build but not released   
  34. [addons]   
  35. name=CentOS-$releasever - Addons   
  36. baseurl=http://mirror.vmmatrix.net/CentOS/$releasever/os/$basearch/   
  37. http://mirror.be10.com/centos/$releasever/os/$basearch/   
  38. http://centos.hostlink.com.hk/$releasever/os/$basearch/   
  39. http://ftp.hostrino.com/pub/centos/   
  40. gpgcheck=1   
  41. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4  
  42.  
  43. #additional packages that may be useful   
  44. [extras]   
  45. name=CentOS-$releasever - Extras   
  46. baseurl=http://mirror.vmmatrix.net/CentOS/$releasever/os/$basearch/   
  47. http://mirror.be10.com/centos/$releasever/os/$basearch/   
  48. http://centos.hostlink.com.hk/$releasever/os/$basearch/   
  49. http://ftp.hostrino.com/pub/centos/   
  50. gpgcheck=1   
  51. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4  
  52.  
  53. #additional packages that extend functionality of existing packages   
  54. [centosplus]   
  55. name=CentOS-$releasever - Plus   
  56. baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/   
  57. gpgcheck=1   
  58. enabled=0   
  59. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4  
  60.  
  61. #contrib - packages by Centos Users   
  62. [contrib]   
  63. name=CentOS-$releasever - Contrib   
  64. baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/   
  65. gpgcheck=1   
  66. enabled=0   
  67. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4  

然后更新一次系统,并将yum设置为自启动,让其即时自动为系统更新。

# yum -y update

# chkconfig yum on

# /etc/rc.d/init.d/yum start

经常会碰到这个问题
http://mirror.be10.com/centos/5/os/i386/repodata/primary.xml.gz: [Errno -1] Metadata file does not match checksum

像这个问题可以用这个方法解决: yum clean metadata

然后重新启用就ok了

版权所有,转载请注明出处。
转载自 <a href="http://www.yanghengfei.com/archives/81/" title="CentOS 升级中国国内镜像" rel="bookmark">CentOS 升级中国国内镜像 | 星外飞客 </a>

我简单说几句

随机推荐

最新评论

无觅相关文章插件,快速提升流量