1,备份repo
mv /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.repo.bak
cd /etc/yum.repos.d/
2,下载repo
[root@node1 yum.repos.d]# wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
--2016-09-18 16:13:12-- http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
Resolving mirrors.sohu.com... 221.236.12.140
Connecting to mirrors.sohu.com|221.236.12.140|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2299 (2.2K) [application/octet-stream]
Saving to: `CentOS-Base-sohu.repo'
100%[======================================================>] 2,299 --.-K/s in 0.06s
2016-09-18 16:13:12 (38.1 KB/s) - `CentOS-Base-sohu.repo' saved [2299/2299]
[root@node1 yum.repos.d]# ll
total 16
-rw-r--r-- 1 root root 2299 Dec 31 2009 CentOS-Base-sohu.repo
-rw-r--r-- 1 root root 561 Sep 18 16:00 rhel-debuginfo.repo.bk
-rw-r--r-- 1 root root 561 Mar 10 2010 rhel-debuginfo.repo.repo.bak
3,修改名字
[root@node1 yum.repos.d]# mv CentOS-Base-sohu.repo rhel-debuginfo.repo
4,yum makecache报错
[root@node1 yum.repos.d]# yum clean all
Loaded plugins: rhnplugin, security
Cleaning up Everything
[root@node1 yum.repos.d]# yum makecache
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/
http://mirrors.sohu.com/centos/5Server/addons/i386/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again
5,替换$releasever 5/6是os版本
[root@node1 yum.repos.d]# vi rhel-debuginfo.repo
$releasever 替换为 5
使用如下命令
:%s/$releasever/5/g
6,再次yum makecache
[root@node1 yum.repos.d]# yum clean all
Loaded plugins: rhnplugin, security
Cleaning up Everything
[root@node1 yum.repos.d]# yum makecache
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
addons | 1.9 kB 00:00
addons/filelists_db | 574 B 00:00
addons/other_db | 550 B 00:00
addons/primary_db | 1.1 kB 00:00
base | 1.1 kB 00:00
base/filelists | 3.1 MB 00:05
base/other | 11 MB 00:23
base/group | 1.1 MB 00:03
base/primary | 996 kB 00:09
extras | 2.1 kB 00:00
extras/filelists_db | 212 kB 00:03
extras/other_db | 432 kB 00:08
extras/group | 9.7 kB 00:00
extras/primary_db | 164 kB 00:00
updates | 1.9 kB 00:00