【问题解决】centos7已经不维护了,如何继续使用yum源?
背景
CentOS 7 已于2024年6月30日停止维护,在停止维护后我们之前配置的国内镜像源大多都是空目录了,即在线国内镜像源不可用,就像下边这样提示:
[root@bogon yum.repos.d]# yum install vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
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).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
那么有没有办法可以继续使用在线镜像源呢?
有的,还不只一种,强烈推荐后两种,我们一起看看。
解决方法
方法1、本地搭建镜像源
作为内网环境使用yum源的方法备用。
1、下载centos7 ISO镜像,下载地址 https://mirrors.huaweicloud.com/centos-vault/7.9.2009/isos/x86_64/ ,推荐选择Everything版本。

2、上传镜像到服务器,以/root目录举例
3、root用户执行命令挂载创建本地镜像源,镜像源目录以/mnt/repo举例
#备份
mkdir /etc/yum.repo.d/bak
mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak/
cp /etc/fstab /etc/fstab.bak
#创建挂载目标目录
mkdir /mnt/repo
#临时挂载,ISO只能只读挂载
mount -o loop /root/CentOS-7-x86_64-Everything-2009.iso /mnt/repo
#创建本地镜像源配置
cat > /etc/yum.repo.d/local.repo<<EOF
[centos-test]
name=centos-test
baseurl=file:///mnt/repo
enable=1
gpgcheck=0
EOF
#更新yum缓存,验证安装
yum clean all && yum makecache
yum install -y vim
#开机自动挂载
echo "/root/CentOS-7-x86_64-Everything-2009.iso /mnt/repo iso9660 loop,defaults 0 0" >> /etc/fstab
方法2、使用阿里镜像源【推荐】
不得不说,阿里的确汇集了很多国内运维人才,目前只看到它家可以镜像源不变就能继续用。
阿里镜像源地址:https://mirrors.aliyun.com/centos/7.9.2009/
#备份
mkdir /etc/yum.repo.d/bak
mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak/
#下载镜像源配置
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
#更新yum缓存,验证安装
yum clean all && yum makecache
yum install -y vim
方法3、使用centos-valut镜像【推荐】
valut有保险的意思,旧版本都会归到这个镜像源中,这里推荐阿里和华为的镜像源,示例以华为镜像源演示(不为别的,就为下载快!)
华为centos-valut镜像源:https://mirrors.huaweicloud.com/centos-vault/
#备份
mkdir /etc/yum.repo.d/bak
mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak/
#下载镜像源配置
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/artifactory/os-conf/centos/centos-7.repo
#更新yum缓存,验证安装
yum clean all && yum makecache
yum install -y vim
全文完,如有帮助麻烦点个赞,我是hellxz,下文见。
【问题解决】centos7已经不维护了,如何继续使用yum源?的更多相关文章
- 在centos7虚拟机上挂载镜像,并设置yum源(包括遇到的问题)
挂载镜像方法很简单: mkdir /etc/a mount /dev/cdrom /etc/a 查看挂载情况 : df -h 修改yum源文件 : 先把 CentOS-Base.repo 文件名改一 ...
- CentOS7.5下基于FTP服务的局域网yum源搭建
实验环境 yum源服务器和yum客户端都处于同一局域网之中 yum源服务器 hostname:zabbix OS版本:CentOS 7.5 IP:192.168.101.201 yum客户端 host ...
- Centos-7修改yum源为国内的yum源
以centos7为例 ,以 修改为阿里的yum源 1. 备份本地yum源 [root@localhost yum.repos.d]# cp CentOS-Base.repo CentOS-Base.r ...
- CentOS-7 本地yum源挂载
在Linux无法连接到互联网时,手动安装依赖是及其麻烦的一件事,需要花费大量的时间寻找rpm包.但在配置本地yum源后,绝决依赖问题就会变得非常简单. 一.准备 centos-7.ISO镜像文件: 二 ...
- [问题解决]RedHat7更换CentOS7的yum源时踩过的坑
更换yum源的流程 查看当前yum程序 $ rpm -qa|grep yum 这里推荐将其结果截屏或拷贝出来,以免后面报错修复. 删除原有yum源 $ rpm -aq | grep yum|xargs ...
- 自建YUM源以及相关维护
yum相关概念我这里就不做详细的讲解了,就是一个软件包管理工具.在企业中,很多时候进行编译了自己的RPM包,在搭建YUM的时候,希望将自定义的RPM加入到YUM源中,从而出现了下列方法. 一.配置私有 ...
- CentOS7 配置阿里云yum源
1)下载repo文件 wget http://mirrors.aliyun.com/repo/Centos-7.repo 2)备份并替换系统的repo文件 cp Centos-7.repo /etc/ ...
- CentOS7.1 JDK安装 和 CentOS7.1配置yum源
1.卸载自带OPENJDK #查看自身jdk java -verson #查看自身安装的java rpm -qa | grep java #显示如下 python-javapackages-3.4. ...
- CentOS7配置更新国内yum源
备份本地yum源文件 cd /etc/yum.repo.d/ mv CentOS-Base.repo CentOS-Base.repo.bakeup 下载国内yum源 阿里云yum源 wget htt ...
- #centos7 创建内网yum源 OpenStack源部署
#centos7 创建内网yum源#centos7 自动化安装 本地 内网 web源创建.更新 createrepo http OpenStack源部署 Elven原创 http://www.cnbl ...
随机推荐
- Linux查看当前Cuda(CUDA Toolkit )版本
纯转载. cat /usr/local/cuda/version.txt nvcc-V nvidia-smi查看的不是当前cuda版本,而是最高支持的cuda版本 https://blog.csdn. ...
- 移动端如何自动适配px
<script type="text/javascript"> (function(doc, win) { var docEl = doc.documentElemen ...
- 天翼云GPU云主机:共享信息技术与虚拟机的完美融合
本文分享自天翼云开发者社区<天翼云GPU云主机:共享信息技术与虚拟机的完美融合>,作者:不知不觉 在云计算领域,GPU云主机已经成为了一个备受瞩目的焦点.它的出现改变了传统IT架构的方式, ...
- 虚拟机设置静态IP并启用桥接模式
虚拟机设置静态IP并启用桥接模式 一.准备工作 在开始之前,请确保你已经安装了VMware或其他虚拟机软件,并且已经创建了一个虚拟机实例. 此外,还需要了解宿主机的网络配置,包括IP地址.子网掩码.网 ...
- nginx出现: [error] open() "/usr/local/nginx/logs/nginx.pid" failed错误
问题情况 登陆服务器之后进到nginx使用./nginx -s reload重新读取配置文件,发现报==nginx: [error] open() "/usr/local/nginx/log ...
- c#securityexception不允许所请求的注册表访问权
开机自启动程序如下: if (!System.IO.File.Exists(filename)) throw new Exception("该文件不存在 ...
- Go实现动态开点线段树
1.线段树介绍 线段树是一种用于高效处理区间查询和区间更新的数据结构,当我们需要解决一个频繁更新区间值的问题的时候,就可以采用线段树的结构进行解决.线段树的核心思想是将区间分为多个子区间进行管理,越往 ...
- Springboot - [06] yaml语法讲解
Yaml是一种标记语言,Yaml也不是一种标记语言. 一.yaml写法示例 application.yaml # 普通的key-value name: harley server.port: 8081 ...
- Shell - 脚本案例
题记部分 一.节点状态监控脚本(nodeStatusCheck.sh) [脚本名称]nodeStatusCheck.sh [监控规则]通过ping的方式监控集群节点状态,检查节点是否失联 [实现方式] ...
- c++经典卡常
1.展开函数 如下代码: void lowbit(int x) { return x&(-x); } signed main() { cout << lowbit(12345); ...