CentOS 6 修改 yun 源
在 CentOS 6 中使用 yum 命令安装时可能会出现以下错误信息:
[root@localhost ~]# yum -y install wget
已加载插件:fastestmirror
设置安装进程
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
错误:Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
出现的原因:CentOS 6 在 2020-11-30 已经结束使用。我们需要修改 yum 源信息,下面是修改 yun 源的方法:
依次输入:
# 进入 yum.repos.d 目录
cd /etc/yum.repos.d/
# 备份 CentOS-Base.repo 文件
cp CentOS-Base.repo CentOS-Base.repo.old
# 编辑 CentOS-Base.repo 文件
vi CentOS-Base.repo
将 CentOS-Base.repo 文件替换成以下内容:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#[base]
name=CentOS-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6#released updates
[updates]
name=CentOS-6.10 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6#additional packages that may be useful
[extras]
name=CentOS-6.10 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.10 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users
[contrib]
name=CentOS-6.10 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
保存 CentOS-Base.repo 文件后依次输入:
# 清理 yun 缓存
yum clean all
# 更新 yun,该过程会比较慢,慢慢等待
yum update
之后使用 yun 命令就不会出问题了
CentOS-Base.repo 文件内容来自阿里