钧言极客站钧言极客

钧言极客

CentOS下卸载和重装yum源

今天在闲置的CentOS的机器打算更新系统,在运行YUM命令不起来,无奈重新各种报错。更换了DNS和安装源等一系列操作还是无法完成更新系统。最后想想还是重装算了,毕竟重装可以解决90%的问题,但是要牵扯很多东西要备份数据重新安装环境等等,但是如果可以尝试修复的就不用重装系统,毕竟可以省掉很多麻烦。

查看和卸载现有Yum源
  • 查看系统是否安装YUM
rpm -qa |grep yum
  • 卸载YUM服务
rpm -qa|grep yum|xargs rpm -e --nodeps
安装yum源

因为我是使用国内服务器,使用国内新的CentOS的Yum包来替换掉redhat自带的Yum服务。
这里我使用阿里云的镜像地址:https://mirrors.aliyun.com/centos/
选择对应的版本进行下载,我的环境CRENTOS 6

wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm 
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget https://mirrors.aliyun.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
  • 安装Python扩展
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm
  • 安装YUM
rpm -ivh  yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
  • 检查是否安装成功
yum -h
rpm -qa |grep yum
更换erpo源和生成缓存
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum clean all
yum makecache
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《CentOS下卸载和重装yum源》
文章链接:https://www.jinjun.top/141.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论