首先备份CentOS-Base.repo
[root@richard yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
其次,下载对应版本的CentOS-Base.repo, 放入/etc/yum.repos.d/目录
CentOS6.x
[root@richard yum.repos.d]# wget http://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=2
CentOS5.x
[root@richard yum.repos.d]# wget http://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=1
运行yum clean all、yum makecache生成缓存
[root@NJZYY06 yum.repos.d]# yum clean all
Loaded plugins: aliases, changelog, downloadonly, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify,
: versionlock
Loading support for CentOS kernel ABI
Cleaning repos: base extras updates
Cleaning up Everything
Cleaning up list of fastest mirrors
11 delta-package files removed, by presto
[root@richard yum.repos.d]# yum makecache
Loaded plugins: aliases, changelog, downloadonly, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify,
: versionlock
Loading support for CentOS kernel ABI
base | 9.4 kB :
http://mirrors.ustc.edu.cn/centos/6/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for base: Damaged repomd.xml file
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
[root@njzyy07 yum.repos.d]# yum makecache
Loaded plugins: aliases, changelog, downloadonly, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify,
: versionlock
Loading support for CentOS kernel ABI
Loading mirror speeds from cached hostfile
base | 3.7 kB :
base/group_gz | kB :
base/filelists_db | 5.9 MB :
base/primary_db | 4.4 MB :
base/other_db | 2.8 MB :
extras | 3.4 kB :
extras/filelists_db | kB :
extras/prestodelta | B :
extras/primary_db | kB :
extras/other_db | 5.8 kB :
updates | 3.4 kB :
updates/filelists_db | 2.2 MB :
updates/prestodelta | kB :
updates/primary_db | 3.7 MB :
updates/other_db | MB :
Metadata Cache Created
运行 yum update升级所有软件包(可以不选)
[root@richard yum.repos.d]# yum update
163网易源配置请参见163官网:http://mirrors.163.com/.help/centos.html