云主机

质量为本、客户为根、勇于拼搏、务实创新

< 返回云主机列表

CentOS7修更换yum源(最简安装)解决默许yum源没法使用

发布时间:2023-07-17

问题:

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⑺.repo

网易163: wget -O CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base⑴63.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⑻.repo

更新数据:

清除缓存: yum clean all

更新缓存:yum makecache

PS:没有源安装wget 显示仓库数量为0,.repo文件出现问题,更换默许yum源便可,由于此时,没法通过yum源安装包括wget在内的任何工具(包括lrzsz等没法安装),新的.repo文件没法下载。可使用xshell的sftp上传下载好的源到vps中。

CentOS7修改换yum源(最简安装)解决默认yum源无法使用

桂&哥&网&络www.guIgEge.cn

TikTok千粉号购买平台:https://tiktokusername.com/