配置yum代理及yum源

本文主要适用于Centos/RedHat 6.5, 其他版本未测试:

配置用于yum的代理:
编辑/etc/yum.conf文件,在文件末尾加上一行:
proxy=http://ip:port/


配置yum源:
可能会有mirror无法解析的问题,这时需要手动添加host,安装过程中注意查看错误信息。
参考hosts信息:
195.220.108.108 fr2.rpmfind.net
112.124.140.210 mirrors.aliyun.com
67.219.144.68 download.fedoraproject.org
219.216.128.25 mirrors.neusoft.edu.cn
101.6.6.172 mirrors.tuna.tsinghua.edu.cn

安装阿里云yum源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
*注意备份原有CentOs-Base.repo
安装epel源:
rpm -ivh http://fr2.rpmfind.net/linux/epel/6/x86_64/epel-release-6-8.noarch.rpm
安装epel之后使用时可能会有Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again.
解决方法:
yum upgrade ca-certificates --disablerepo=epel -y
sed -i 's/#baseurl/baseurl/g' /etc/yum.repos.d/epel.repo
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/epel.repo


配置redhat6.5yum源:

首先删除redhat自带的yum:
rpm -qa|grep yum|xargs rpm -e --nodeps

下载CentOS的yum及安装所需依赖:
wget mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
wget mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm

手动安装yum命令:
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -Uvh python-urlgrabber-3.9.1-11.el6.noarch.rpm
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm

安装完成后,删除/etc/yum.repo.d中的redhat.repo。之后按照centos配置yum源方法配置即可。

发表评论

您的电子邮箱地址不会被公开。