redhat 5 更换yum源

将redhat5的源更换为163的源

redhat的版本是5.8, 以下操作都在用户目录下进行

1.删除系统原来的yum软件包

rpm -aq|grep yum|xargs rpm -e --nodeps

2.下载相应的rpm包,下载rpm包时,可能软件的版本会有不一致的情况,请自行查询相应的版本

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-metadata-parser-1.1.2-4.el5.x86_64.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/python-iniparse-0.2.3-6.el5.noarch.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/centos-release-5-11.el5.centos.x86_64.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/centos-release-notes-5.11-0.x86_64.rpm

3.下载163源配置文件,并将配置文件中的$releasever进行替换

wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
sed -i "s/\$releasever/5/g" /root/CentOS5-Base-163.repo
 
4.备份yum原来的配置文件,并将配置文件复制到/etc/yum.repos.d/目录
for f in /etc/yum.repos.d/*; do mv ${f} ${f}.bak ; done
cp /root/CentOS5-Base-163.repo /etc/yum.repos.d/CentOS-Base.repo
 
5.安装yum相关软件包
rpm -ivh --force *.rpm
 
6.清理,并生成缓存
yum clean all
yum makecache
 
脚本可到github下载
https://github.com/hahsuu/linux/blob/master/yum_5.8.sh
 

转载于:https://www.cnblogs.com/panchong/p/6026438.html

你可能感兴趣的:(redhat 5 更换yum源)