centos重装yum
入坑原因:执行了yum -y update(欲哭无泪)
一、 清除已有的应用与依赖
1、删除现有Python
[root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联 [root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令 [root@test ~]# whereis python ##验证删除,返回无结果 2、删除现有的yum [root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps [root@test ~]# whereis yum |xargs rm -frv
二、下载相关的应用包(以centos6.10为例)
1. 创建存放rpm包的文件夹(我存放在home的rpm目录下)
cd /home mkdir rpm
2. 可以创建一个sh脚本:vim t.sh(可以在该网站找到相应的应用包:http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/ 注:路径上的6.10是系统版本号 centos系统版本号可以通过cat /etc/issue命令来查看)
1 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm 2 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm 3 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm 4 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm 5 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/python-setuptools-0.6.10-4.el6_9.noarch.rpm 6 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm 7 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm 8 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/rpm-python-4.8.0-59.el6.x86_64.rpm 9 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm 10 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 11 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/yum-utils-1.1.30-41.el6.noarch.rpm 12 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm 13 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/yum-plugin-protectbase-1.1.30-41.el6.noarch.rpm 14 wget http://mirrors.ustc.edu.cn/centos/6.10/os/x86_64/Packages/yum-plugin-aliases-1.1.30-41.el6.noarch.rpm
3. 执行脚本下载应用包
./t.sh
三、 安装相关应用包(-ivh:覆盖安装 -Uvh:升级安装)
1. 安装python
rpm -ivh python-* rpm-python-*
出现安装包的依赖问题,此时如下解决即可:rpm -ivh python-* rpm-python-* --nodeps --force
2. 安装yum
rpm -ivh yum-*
四、 测试是否安装成功
yum