在目前的系统安装gcc,会出现以下问题
[root@bes2 ~]# yum install gcc
Loaded plugins: rhnplugin
Loaded plugins: rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
http://centos.ustc.edu.cn/centos/5/addons/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - ""
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again
RHN support will be disabled.
http://centos.ustc.edu.cn/centos/5/addons/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - ""
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again
原因:目前的repo文件里面的源不是可用的
解决方法:下载最新的repo文件,替换目前系统中的repo文件,yum的repo文件放在/etc/yum.repos.d文件夹中,替换前需将目前文件夹中的其他repo文件修改为备份文件,每个文件的文件名后添加.bak后缀
[root@bes2 ~]# cd /etc/yum.repos.d/ ——进入对应的文件夹
[root@bes2 yum.repos.d]# mv rhel-debuginfo.repo rhel-debuginfo.repo.bak ——修改原来已有文件为备份文件
[root@bes2 yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo ——下载最新的repo文件
[root@bes2 yum.repos.d]# vim CentOS6-Base-163.repo ——编辑下载的repo文件,编辑前记得先备份
:1,$s/$releasever/6/g ——在编辑模式下,将整个文件中的$releasever替换为当前的版本号,例如我的是6
[root@bes1 yum.repos.d]# yum clean all ——清除yum缓存
[root@bes1 yum.repos.d]# yum makecache ——把服务器的包信息下载到本地电脑缓存起来
完成上述更新后,再执行yum install gcc时,可正常安装gcc