redhat换yum源

根据redhat操作系统版本及位数,下载对应centos的版本及位数的这些包:
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
yum-metadata-parser-1.1.2-4.el5.i386.rpm 
1.先卸载原来的yum
rpm -qa | grep yum
结果回显:
yum-metadata-parser-1.1.2-4.el5
yum-fastestmirror-1.1.16-21.el5.centos

.....

运行命令:

rpm -e yum-metadata-parser-1.1.2-4.el5 --nodeps

依次把上面列出的全部卸载

 

2.准备安装yum

如果是32位,删除包yum-metadata-parser-1.1.2-4.el5.x86_64.rpm

如果是64位,删除包yum-metadata-parser-1.1.2-4.el5.i386.rpm

现在只剩下三个包了,然后运行命令:

rpm -ivh *.rpm

3.获取163yum:
文件内容替换:
 把CentOS-Base-163.repo文件中的 “$releasever”,替换成“5”(5为系统的版本号。)
    vi CentOS-Base-163.repo 
    :% s/\$releasever/5/g
 

[base]   

name=CentOS-$releasever - Base   

baseurl=http://mirrors.163.com/centos/6.3/os/$basearch/   

gpgcheck=1   

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6   

  

#released updates   

[updates]   

name=CentOS-$releasever - Updates   

baseurl=http://mirrors.163.com/centos/6.3/updates/$basearch/   

gpgcheck=1   

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6   

  

#packages used/produced in the build but not released   

#[addons]   

#name=CentOS-$releasever - Addons   

#baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/   

#gpgcheck=1   

#gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6   

#additional packages that may be useful   

[extras]   

name=CentOS-$releasever - Extras   

baseurl=http://mirrors.163.com/centos/6.3/extras/$basearch/   

gpgcheck=1   

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6   

#additional packages that extend functionality of existing packages   

[centosplus]   

name=CentOS-$releasever - Plus   

baseurl=http://mirrors.163.com/centos/6.3/centosplus/$basearch/   

gpgcheck=1   

enabled=0 

 

 

4.yum文件拷贝到/etc/yum.repos.d

cp ./CentOS-Base-163.repo  /etc/yum.repos.d/

 

5.更新yum缓存

yum makecache

你可能感兴趣的:(redhat,yum)