知识库
AI技术
并发编程
  • 分类
  • 标签
  • 归档
友情连接

luoliang

吾生也有涯,知也无涯
AI技术
并发编程
  • 分类
  • 标签
  • 归档
友情连接
  • 灰度发布、蓝绿部署、金丝雀都是啥?
  • ELK日志系统安装
  • nacos优雅停机
  • 搭建jenkins部署spring-boot项目
  • 安装RocketMQ
  • 安装监控grafana
  • SpringBoot启动脚本
  • Linux常用命令
  • wiregurd
  • tailscale异地组网
  • caddy安装
  • 解决centos7 yum失效的问题
    • 1. 查看当前有哪些是在使用的
    • 2. 备份配置
    • 安装阿里云yum源
    • 清理缓存并测试
  • DevOps
weiluoliang
2025-06-25
目录

解决centos7 yum失效的问题

# 1. 查看当前有哪些是在使用的

# 查看所有仓库配置文件
ls -l  /etc/yum.repos.d/

总用量 56
-rw-r--r--. 1 root root 2523 8月   2 2024 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 10月 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 2081 8月   2 2024 docker-ce.repo
-rw-r--r--. 1 root root  951 10月  3 2017 epel.repo
-rw-r--r--. 1 root root 1050 10月  3 2017 epel-testing.repo
-rw-r--r--. 1 root root    0 7月  23 2024 jenkins.repo
-rw-r--r--. 1 root root  477 4月  27 2014 nux-dextop.repo

# 查看当前启用的仓库
yum repolist all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# 2. 备份配置

# 创建备份目录
mkdir -p /root/yum-repos-backup

# 备份所有仓库配置
cp /etc/yum.repos.d/*.repo /root/yum-repos-backup/
1
2
3
4
5

# 安装阿里云yum源

# 删除之前的所有配置
rm -rf /etc/yum.repos.d/*

# 配置阿里云
# 检查阿里云网络是否正常
curl -I http://mirrors.aliyun.com/centos-vault/7.9.2009/os/x86_64/

# 创建新的完整仓库配置
cat > /etc/yum.repos.d/CentOS-Base.repo << 'EOF'
[base]
name=CentOS-7 - Base
baseurl=http://mirrors.aliyun.com/centos-vault/7.9.2009/os/x86_64/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-7 - Updates
baseurl=http://mirrors.aliyun.com/centos-vault/7.9.2009/updates/x86_64/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-7 - Extras
baseurl=http://mirrors.aliyun.com/centos-vault/7.9.2009/extras/x86_64/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7

[centosplus]
name=CentOS-7 - Plus
baseurl=http://mirrors.aliyun.com/centos-vault/7.9.2009/centosplus/x86_64/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
EOF
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

创建EPEL仓库配置

# 创建EPEL仓库配置
cat > /etc/yum.repos.d/epel.repo << 'EOF'
[epel]
name=Extra Packages for Enterprise Linux 7 - x86_64
baseurl=http://mirrors.aliyun.com/epel/7/x86_64/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7
EOF
1
2
3
4
5
6
7
8
9

# 清理缓存并测试

# 清理所有缓存
yum clean all

# 重新生成缓存
yum makecache

# 测试仓库连接
yum repolist enabled
1
2
3
4
5
6
7
8
上次更新: 2025/06/28, 10:25:16
caddy安装

← caddy安装

最近更新
01
caddy安装
06-23
02
tailscale异地组网
06-20
03
wiregurd
06-19
更多文章>
Theme by Vdoing | Copyright © 2022-2025 Evan Xu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式