1. 程式人生 > >Redhat7.6 yum源替換阿裏yum源

Redhat7.6 yum源替換阿裏yum源

替換 rpm -e get 一行 ima 可能 rpm安裝 一次 args

1.下載所需要的rpm安裝包(可能有些包之間的小版本好不一樣,可以直接去阿裏雲上下載)
https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
技術分享圖片

2.查詢yum包和刪除yum現有rpm包,刪完以後再查看一下,是否刪除幹凈,刪除完成後安裝剛剛下載好的rpm包,yum包安裝時必須取消依賴關系和強制安裝
rpm -qa | grep yum
rpm -qa | grep yum | xargs rpm -e --nodeps

rpm -ivh python-urlgrabber-3.10-9.el7.noarch.rpm
rpm -ivh yum-* --force --nodeps
技術分享圖片

3.將現有的redhat .repo的包重命名,再下載阿裏雲的.repo到/etc/yum.repos.d目錄下
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
技術分享圖片

4.修改剛下載的.repo文件,將裏面所有$releasever替換為7
vim CentOS-Base.repo
:%s/$releaserver/7/g --/g 表示一行當中如果出現了多次,每一次都替換

技術分享圖片

5.運行以下命令
yum clean all
yum makecache
yum update

Redhat7.6 yum源替換阿裏yum源