问题:
1.CentOS解决yum命令出现doesn’t have enough cached的问题
One of the configured repositories failed (未知),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
2.单纯修改源,使得国内更新为国内源,下载软件更快。
3.报错:yum 命令报错 “ There are no enabled repos ” —— yum repolist 为 0
首先修改DNS:
vi /etc/resolv.conf
nameserver: 8.8.8.8(或者国内机器可修改为114.114.114.114)
进入yum源配置目录: cd /etc/yum.repos.d(yum repolist命令查看可用源数量)
备份原有源:mv /etc/yum.repos.d /etc/yum.repos.d.bak
如果没有先安装wget就: yum install wget -y
修改yum源,就是修改CentOS-Base.repo的内容,所以我们要先备份一下原来的:
mv CentOS-Base.repo CentOS-Base.repo.backup
下载新的配置文件:
wget下载国内的yum源(即CentOS-Base.repo文件),目前国内主要有三个yum源:(三选一即可)
阿里云: wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
网易163: wget -O CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
中科大(推荐):
wget -O CentOS-Base.repo https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=3
CentOS 8:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
更新数据:
清除缓存: yum clean all
更新缓存:yum makecache
PS:没有源安装wget 显示仓库数量为0,.repo文件出现问题,更换默认yum源即可,由于此时,无法通过yum源安装包括wget在内的任何工具(包括lrzsz等无法安装),新的.repo文件无法下载。可以使用xshell的sftp上传下载好的源到vps中。