redhat 5 更換yum源

將redhat5的源更換爲163的源node

redhat的版本是5.8, 如下操做都在用戶目錄下進行python

1.刪除系統原來的yum軟件包linux

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

2.下載相應的rpm包,下載rpm包時,可能軟件的版本會有不一致的狀況,請自行查詢相應的版本git

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進行替換github

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下載
相關文章
相關標籤/搜索