CentOS7 重装 yum
首先安装 wget
//下载rpm文件,上传服务器,然后使用 rpm 安装
http://mirrors.163.com/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm rpm -ivh wget-1.14-18.el7_6.1.x86_64.rpm
https://www.cnblogs.com/DiZhang/p/12544744.html
第一步: 卸载
rpm -aq|grep yum|xargs rpm -e --nodeps
第二部,到该地址 http://mirrors.163.com/centos/7/os/x86_64/Packages/ 查找以下包,并下载到同一个目录,例如如下
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm && \
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm && \
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm && \
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm && \
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm && \
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm && \
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm && \
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
所有包下载完之后,有的可能版本会不一样,选择相近的版本即可
-rw-r--r-- 1 root root 98100 10月 15 02:59 python-2.7.5-89.el7.x86_64.rpm -rw-r--r-- 1 root root 39800 7月 4 2014 python-iniparse-0.4-9.el7.noarch.rpm -rw-r--r-- 1 root root 5919140 10月 15 02:59 python-libs-2.7.5-89.el7.x86_64.rpm -rw-r--r-- 1 root root 82396 11月 21 2016 python-pycurl-7.19.0-19.el7.x86_64.rpm -rw-r--r-- 1 root root 111048 4月 4 2020 python-urlgrabber-3.10-10.el7.noarch.rpm -rw-r--r-- 1 root root 1298856 10月 15 03:21 yum-3.4.3-168.el7.centos.noarch.rpm -rw-r--r-- 1 root root 28348 7月 4 2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm -rw-r--r-- 1 root root 35216 5月 14 2020 yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
第三步: 安装下载的包和依赖, 需要用
rpm -ivh python-*
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm yum-3.4.3-168.el7.centos.noarch.rpm
第四步:修改源
cd /etc/yum.repos.d/
wget http://mirrors.aliyun.com/repo/Centos-7.repo
mv Centos-7.repo CentOS-Base.repo
第五步: 验证
yum -y install yum-utils
本文来自博客园踩坑狭,作者:韩若明瞳,转载请注明原文链接:https://www.cnblogs.com/han-guang-xue/p/14506850.html