[root@zf-test-web01-4 ~]# yum install rng-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 You can enable repos with yum-config-manager --enable <repo>

红色部分问题解决如下:

-bash-4.2# vi /etc/yum/pluginconf.d/fastestmirror.conf

[main]
enabled=0
verbose=0
always_print_best_host = true
socket_timeout=3
#  Relative paths are relative to the cachedir (and so works for users as well
# as root).
hostfilepath=timedhosts.txt
maxhostfileage=10
maxthreads=15
#exclude=.gov, facebook

把enabled=1改为enabled=0

再次执行yum安装,仍报错

[root@zf-test-web01-4 ~]# yum install -y rng-tools
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 You can enable repos with yum-config-manager --enable <repo>

也就是蓝色部分,解决办法:

1. 查看centos7.2系统本身所安装的那些yum 软件包

[root@zf-test-web01-4 ~]# rpm -qa|grep yum
yum-plugin-fastestmirror-1.1.31-34.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-132.el7.centos.0.1.noarch

[root@zf-test-web01-4 ~]#

2. 卸载这些软件包

[root@zf-test-web01-4 ~]# rpm -e yum-plugin-fastestmirror-1.1.31-34.el7.noarch --nodeps
warning: /etc/yum/pluginconf.d/fastestmirror.conf saved as /etc/yum/pluginconf.d/fastestmirror.conf.rpmsave
[root@zf-test-web01-4 ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[root@zf-test-web01-4 ~]# rpm -e yum-3.4.3-132.el7.centos.0.1.noarch --nodeps
[root@zf-test-web01-4 ~]#

3. 进入centos镜像网站找到自己对应系统需要的yum包

查看系统的命令:

[root@zf-test-web01-4 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

查看系统的位数:

[root@zf-test-web01-4 ~]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=aa7ff68f13de25936a098016243ce57c3c982e06, stripped

http://vault.centos.org/

4. 下载这些yum包

wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm

5. 安装下载的这些yum包

[root@zf-test-web01-4 ~]# rpm -ivh yum-*
Preparing...                          ################################# [100%]
Updating / installing...
   1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 33%]
   2:yum-plugin-fastestmirror-1.1.31-3################################# [ 67%]
   3:yum-3.4.3-132.el7.centos.0.1     ################################# [100%]
[root@zf-test-web01-4 ~]#

6. 更新centos系统的repo文件

http://mirrors.163.com/.help/centos.html

1)首先备份/etc/yum.repos.d/CentOS-Base.repo

[root@zf-test-web01-4 yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2)下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)

3)运行以下命令生成缓存

[root@zf-test-web01-4 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@zf-test-web01-4 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
base                                                             | 3.6 kB  00:00:00     
extras                                                           | 3.4 kB  00:00:00     
updates                                                          | 3.4 kB  00:00:00     
(1/12): base/7/x86_64/group_gz                                   | 156 kB  00:00:00     
(2/12): base/7/x86_64/filelists_db                               | 6.7 MB  00:00:01     
(3/12): extras/7/x86_64/prestodelta                              |  71 kB  00:00:00     
(4/12): extras/7/x86_64/primary_db                               | 145 kB  00:00:00     
(5/12): extras/7/x86_64/filelists_db                             | 528 kB  00:00:00     
(6/12): extras/7/x86_64/other_db                                 |  97 kB  00:00:00     
(7/12): updates/7/x86_64/prestodelta                             | 589 kB  00:00:00     
(8/12): base/7/x86_64/primary_db                                 | 5.7 MB  00:00:01     
(9/12): base/7/x86_64/other_db                                   | 2.5 MB  00:00:00     
(10/12): updates/7/x86_64/primary_db                             | 4.5 MB  00:00:00     
(11/12): updates/7/x86_64/other_db                               | 490 kB  00:00:00     
(12/12): updates/7/x86_64/filelists_db                           | 2.7 MB  00:00:01     
Determining fastest mirrors
Metadata Cache Created

7. 重新运用yum安装软件

---------------------
作者:shaoqiufeng
来源:CSDN
原文:https://blog.csdn.net/shaoqiufeng/article/details/78785806?utm_source=copy
版权声明:本文为博主原创文章,转载请附上博文链接!

centos7.2重新安装yum的更多相关文章

  1. Centos7重新安装yum

    Centos7重新安装yum rpm -qa|grep yum 然后用下面的命令删除出现的xxx包: rpm -e --nodeps xxx 下载 python-urlgrabber-3.10-8.e ...

  2. centos7下使用yum安装mysql

    CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 wget http://repo.mysql.com/m ...

  3. CentOS7下使用YUM安装mariadb10

    1:由于centos7 默认使用yum安装MySQL的话就会安装mariadb,只是安装的版本停留在mariadb5.x,版本比较低.如果我们需要安装mariadb10这里就需要删除mariadb-l ...

  4. centos7下使用yum安装pip

    centos7下使用yum安装pip 首先安装epel扩展源: yum -y install epel-release 更新完成之后,就可安装pip: yum -y install python-pi ...

  5. <亲测>CentOS7中使用yum安装Nginx的方法

    CentOS7中使用yum安装Nginx的方法   最近无意间发现Nginx官方提供了Yum源.因此写个文章记录下. 1.添加源 默认情况Centos7中无Nginx的源,最近发现Nginx官网提供了 ...

  6. 在CentOS7中利用yum命令安装mysql

    在CentOS7中利用yum命令安装mysql 原创 2016年08月31日 10:42:33 标签: mysql / centos 4832 一.说明 我们是在VMware虚拟机上安装的mysql, ...

  7. CentOS7创建本地YUM源的三种方法

    这篇文章主要介绍了CentOS7创建本地YUM源的三种方法,本文讲解了使用CentOS光盘作为本地yum源.如何为CentOS创建公共镜像.创建完全自定义的本地源等内容,需要的朋友可以参考下     ...

  8. centos7.2环境yum方式快速搭建lnmp环境nginx+mariadb+php-fpm

    centos7.2环境yum方式安装nginx+mariadb+php-fpm 1.安装lnmp环境 安装epel源 yum install -y epel-release 安装 MySQL + PH ...

  9. centos7中使用yum安装tomcat以及它的启动、停止、重启

    centos7中使用yum安装tomcat 介绍 Apache Tomcat是用于提供Java应用程序的Web服务器和servlet容器. Tomcat是Apache Software Foundat ...

随机推荐

  1. java.io.File中字段的使用

    File.pathSeparator指的是分隔连续多个路径字符串的分隔符,例如:Java   -cp   test.jar;abc.jar   HelloWorld就是指“;” File.separa ...

  2. 在jsp页面上方定义<style> 可以自定义class的样式

    <style>.border-orange{ border:1px solid orange; width:120px; box-sizing: border-box; margin-bo ...

  3. 【JavaScript】浏览器

    No1: [window]全局作用域,而且表示浏览器窗口 innerWidth和innerHeight属性,可以获取浏览器窗口的内部宽度和高度.内部宽高是指除去菜单栏.工具栏.边框等占位元素后,用于显 ...

  4. 【Spring Boot】使用JDBC 获取相关的数据

    使用JDBC 获取相关的数据 什么是JDBC Java Database Connectivity 是一种用于执行SQL语句的Java API,与数据库建立连接.发送 操作数据库的语句并处理结果. S ...

  5. JavaScript函数、闭包、原型、面向对象

    JavaScript函数.闭包.原型.面向对象 断言 单元测试框架的核心是断言方法,通常叫assert(). 该方法通常接收一个值--需要断言的值,以及一个表示该断言目的的描述. 如果该值执行的结果为 ...

  6. 使用 universalimageloader 缓存图片的配置类及使用方法

    0.gradle 配置 dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:juni ...

  7. 英语口语练习系列-C30-生日-年历的周日和月份-如果白昼落进

    词汇-生日-birthday 生日庆祝 birthday celebration birth noun UK /bɜːθ/ US /bɝːθ/ the time when a baby or youn ...

  8. 潭州课堂25班:Ph201805201 django框架 第四课 模板常用标签,模板继承与引用,自定义过渡器 (课堂笔记)

    if 语句 判断传入的 name 值 建好这些文件后,对 url 进行配置 在浏览器中访问 for 循环 页面跳转: 通过  name 跳转时要在 urls 文件中为该 path 设置 name 带参 ...

  9. C++学习笔记50:队列类模板

    队列是只能向一端添加元素,从另一端删除元素的线性群体 循环队列 在想象中将数组弯曲成环形,元素出队时,后继元素不移动,每当队尾达到数组最后一个元素时,便再回到数组开头. 队列类模板 //Queue.h ...

  10. 分金币 [CQOI 2011] [BZOJ 3293]

    Description 圆桌上坐着n个人,每人有一定数量的金币,金币总数能被n整除.每个人可以给他左右相邻的人一些金币,最终使得每个人的金币数目相等.你的任务是求出被转手的金币数量的最小值. Inpu ...