CentOS 7操作系统在2024年6月30日后将停止官方维护,并且官方提供的YUM源将不再可用。因此,为了继续使用YUM进行软件包管理和更新,我们需要配置国内的YUM源,以便从国内镜像站点获取软件包和更新。
出现问题:使用yum相关指令出现以下内容
排查一
检查防火墙已经处于关闭状态(当然即使未关闭也可能不是他的问题)
systemctl status firewalld.service
关闭防火墙
systemctl stop firewalld.service
排查二
网络问题
(1)检查能否ping通百度,检查网络问题
ping www.baidu.com
(2)检查是否有IP
ip addr
(3)检查网卡文件
vi /etc/sysconfig/network-scripts/ifcfg-ens32
ONBOOT有可能是no,将其改为yes,即打开网络,可能是安装系统的时候没有配置
(4)虚拟网络的网段和物理主机的网段不一致
排查三
若执行完以上操作还未解决问题,那么可能是yum源的问题,需要进行更换镜像,下面以清华镜像为例
- 打开配置yum所在文件,CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo
- 将CentOS-Base.repo里的内容全部替换为以下内容
# CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# 使用failovermethod指定优先级,这里设置为随机(roundrobin),也可以改为priority并指定每个URL的优先级
failovermethod=roundrobin
- 清理YUM缓存并更新
yum clean all
yum makecache
yum update