Skip to content

创建目录

mkdir yum
cd yum/

下载依赖包

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-urlgrabber-3.10-10.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-43.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-167.el7.centos.noarch.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-53.el7.noarch.rpm

移除旧的 yum

rpm -qa|grep yum
rpm -qa|grep yum|xargs rpm -e --nodeps     #不检查依赖直接删除所有yum包。
rpm -qa|grep yum
# 没有内容表明删除成功。

安装 yum

rpm -ivh yum-3.4.3-167.el7.centos.noarch.rpm \ 
 yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm \ 
 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -Uvh rpm-4.11.3-43.el7.x86_64.rpm --nodeps

编辑源

cd /etc/yum.repos.d
ls
mv redhat.repo redhat.repo.bak
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
vi CentOS7-Base-163.repo
# :1,$s/$releasever/7   #直接执行
# :ws

清理缓存,重新建立缓存

yum clean all
yum makecache
yum repolist

安装第三方包

yum install  vim
yum install lsof
yum -y install net-tools
yum install  sysstat

参考

https://blog.csdn.net/allthebetter/article/details/105561487