redhat 修改yum源

问题现象:

现有的yum安装git失败,提示yum源连接失败

Error Downloading Packages:
  git-1.7.1-3.el6_4.1.x86_64: failure: Packages/git-1.7.1-3.el6_4.1.x86_64.rpm from rhel-source: [Errno 256] No more mirrors to try.
  1:perl-Error-0.17015-4.el6.noarch: failure: Packages/perl-Error-0.17015-4.el6.noarch.rpm from rhel-source: [Errno 256] No more mirr
ors to try.  perl-Git-1.7.1-3.el6_4.1.noarch: failure: Packages/perl-Git-1.7.1-3.el6_4.1.noarch.rpm from rhel-source: [Errno 256] No more mirror
s to try.

解决方法:

修改Yum源,使用新的yum源更新

1.首先卸载原来的yum

rpm -qa|grep yum|xargs rpm -e --nodeps   移除与原yum所有有关的东西

2.下载yum包,使用163的Yum源

需要登陆 http://mirrors.163.com/centos/  确认使用的安装包名称

  ps:redhat 与centos的版本对应关系  

https://blog.csdn.net/xiexievv/article/details/42238835

https://www.cnblogs.com/Sungeek/p/9924183.html

需要的包:rpm、yum-metadata-parser、python-urlgrabber、yum、yum-plugin-fastestmirror ,对应的版本到 http://mirrors.163.com/centos/  下查找对应的包下载

3.安装yum包

rpm -ivh --force 包的名称

[root@linuxprobe~]# rpm -ivh yum-fastestmirror-1.1.26-11.el6.centos.noarch.rpm

error: Failed dependencies:
yum >= 3.0 is needed by yum-fastestmirror-1.1.26-11.el6.centos.noarch

[root@linuxprobe~]# rpm -ivh yum-3.2.27-14.el6.centos.noarch.rpm

error: Failed dependencies:
yum-fastestmirror is needed by yum-3.2.27-14.el6.centos.noarch

出现2个rpm包互相依赖,

通过2个包同时安装解决:

如:rpm -ivh yum-3.2.27-14.el6.centos.noarch.rpm yum-fastestmirror-1.1.26-11.el6.centos.noarch.rpm

4.下载、修改配置文件

根据自己系统的版本下载CentOS6或者7的配置文件(建议自己登到网址http://mirrors.163.com/.help/centos.html 去了解一下)

下载对应的配置文件,如wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

下载完毕,首先将原yum文件备份,如:mv /etc/yum.repos.d/redhat.repo /etc/yum.repos.d/redhat.repo.bak

然后更改文件centos7-Base-163.repo中的$releasever变量,更改为实际版本号

5.进行yum初始化和检验操作

清理原有缓存      yum clean all

重建缓存            yum makecache

安装测试           yum -y install httpd

posted @ 2019-09-19 09:39  寒星月冷  阅读(2707)  评论(0编辑  收藏  举报