centos设置网络源
http://mirrors.163.com/.help/centos.html
具体原理为什么原因请看最下面的解释。
方法一:
更换网络源:
1. 卸载自带的rpm rpm -qa |grep rpm
rpm -qa|grep yum |xargs rpm -e --nodeps
2. 安装centos用的yum
wget http://vault.centos.org/5.5/os/x86_64/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm
wget http://vault.centos.org/5.5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm
wget http://vault.centos.org/5.5/os/x86_64/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm(可有可无)
wget http://vault.centos.org/5.5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
3. 下载163源
wget http://mirrors.163.com/.help/CentOS5-Base-163.repo (将原来的备份一下)
vi CentOS5-Base-163.repo 把其中的$releasever全部替换成5
:s@$releasever@5@g 因为有$变量 此时用/报错 所以用@
4. 导入证书 先下载再导入
wget http://vault.centos.org/5.5/os/x86_64/RPM-GPG-KEY-CentOS-5
rpm --import http://vault.centos.org/5.5/os/x86_64/RPM-GPG-KEY-CentOS-5
5. yum clean all
6. yum makecache
方法二:
Redhat Linux通常由于没有注册,导致yum程序无法使用,需要将其替换为centos的yum程序。
1. 下载Yum的安装包,由于体系结构的不同和包的更新,因此目录和文件名的版本号可能需要调整以下。
#wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
#wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
#wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-4.el5.x86_64.rpm
2. 查出当前的yum程序,进行卸载
#rpm -qa|grep yum
# rpm -e yum-3.2.22-20.el5 --nodeps
# rpm -e yum-updatesd-0.9-2.el5 --nodeps
# rpm -e yum-security-1.1.16-13.el5 --nodeps
# rpm -e yum-metadata-parser-1.1.2-3.el5 --nodeps
# rpm -e yum-rhn-plugin-0.5.4-13.el5 --nodeps
3. 下载并导入KEY
# cd /etc/pki/rpm-gpg/
# wget http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
4. 安装yum安装包
rpm -ivh yum-3.2.22-40.el5.centos.noarch.rpm \
yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm \
yum-metadata-parser-1.1.2-4.el5.x86_64.rpm
5. 修改配置文件
mv /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.bak
vi /etc/yum.repos.d/rhel-debuginfo.repo
[base]
name=Red Hat Enterprise Linux $releasever -Base
baseurl=http://mirrors.163.com/centos/5/os/$basearch/
gpgcheck=1
[update]
name=Red Hat Enterprise Linux $releasever -Updates
baseurl=http://mirrors.163.com/centos/5/updates/$basearch/
gpgcheck=1
[extras]
name=Red Hat Enterprise Linux $releasever -Extras
baseurl=http://mirrors.163.com/centos/5/extras/$basearch/
gpgcheck=1
[addons]
name=Red Hat Enterprise Linux $releasever -Addons
baseurl=http://mirrors.163.com/centos/5/addons/$basearch/
gpgcheck=1
6、清理yum源
yum clean all
7、yum install vim #测试一下可不可以用
至此yum安装完成,可以 yum install 安装程序了
注释: 现在网络上很多redhat5.5设置163网络源 都失效了,是因为163源不提供redhat5版本的更新了,里面只留了个文档 ,不过里面写的很清楚 ,
This directory (and version of CentOS) is deprecated. For normal users,
you should use /5/ and not /5.5/ in your path. Please see this FAQ
concerning the CentOS release scheme:
If you know what you are doing, and absolutely want to remain at the 5.5
level, go to http://vault.centos.org/ for packages. Please keep in mind that 5.5 no longer gets any updates
翻译:
此目录(和版本的CentOS的)已经过时了。对于普通用户来说,
你应该使用/5/在你的路径不/5.5/。请参阅此常见问题解答
关于CentOS的发行方案:
https://wiki.centos.org/FAQ/General
如果你知道你在做什么,绝对要保持在5.5
的水平,去http://vault.centos.org/~~V包。请记住,5.5不再获得任何更新
可以去
http://vault.centos.org/5.5/os/x86_64 寻找我们需要的
本文出自 “kobebryant” 博客,谢绝转载!