备份阿里源配置文件
[root@rhel64 yum.repos.d]# ls
CentOS-Base.repo packagekit-media.repo rhel-source.repo rhel-source.repo.bak
[root@rhel64 yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
下载阿里源配置文件(2种方式)
[root@rhel64 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 8661 0 --:--:-- --:--:-- --:--:-- 14335
另一下载方式
[root@localhost ~]#wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
更新镜像源
[root@rhel64 yum.repos.d]# ls
CentOS-Base.repo packagekit-media.repo rhel-source.repo rhel-source.repo.bak
[root@rhel64 yum.repos.d]# yum clean all
Failed to set locale, defaulting to C
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: InstallMedia base extras rhel64 updates
Cleaning up Everything
[root@rhel64 yum.repos.d]# yum makecache
Failed to set locale, defaulting to C
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base | 3.6 kB 00:00
base/group_gz | 153 kB 00:00
base/filelists_db | 7.2 MB 00:10
base/primary_db | 6.1 MB 00:08
base/other_db | 2.6 MB 00:03
extras | 2.9 kB 00:00
extras/filelists_db | 276 kB 00:00
extras/primary_db | 249 kB 00:00
extras/other_db | 149 kB 00:00
updates | 2.9 kB 00:00
updates/filelists_db | 12 MB 00:17
updates/primary_db | 22 MB 00:34
updates/other_db | 1.4 MB 00:02
Metadata Cache Created
1如果发生如下报错:http://mirrors.aliyun.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 – Not Found
2报错原因:Centos-base.repo配置文件中的
r
e
l
e
a
s
e
v
e
r
变量解析错误,导致整个
u
r
l
地址错误。这种情况一般发生在
r
e
d
h
a
t
系统安装
c
e
n
t
o
s
源,
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
/
c
e
n
t
o
s
/
,
发现并无
7
s
e
r
v
e
r
/
目录。因此,应该是
releasever变量解析错误,导致整个url地址错误。这种情况一般发生在redhat系统安装centos源,http://mirrors.aliyun.com/centos/,发现并无7server/目录。因此,应该是
releasever变量解析错误,导致整个url地址错误。这种情况一般发生在redhat系统安装centos源,http://mirrors.aliyun.com/centos/,发现并无7server/目录。因此,应该是releasever变量解析成了7server,进而导致了错误的发生
3
解决办法:
#1、修改yum配置文件
[wanchao@localhost ~]$ vim /etc/yum.repos.d/CentOS-Base.repo
#2、将全文中所有的“KaTeX parse error: Expected 'EOF', got '#' at position 38: …为我的系统centos7版本 #̲进入命令行模式 :%s/releasever/7/g
#保存并退出
:wq
再次更新镜像源
[wanchao@localhost ~]$ yum clean all
[wanchao@localhost ~]$ yum makecache
链接:https://www.jianshu.com/p/4d6943110841