运行“yum repolist”时报错:“parsing errors”

问题

在现有的 yum 存储库配置文件中添加公共 yum 的另外存储库时,显示以下错误:

# yum repolist
Loaded plugins: langpacks, ulninfo
File contains parsing errors: file:///etc/yum.repos.d/public-yum-ol7.repo
[line 91]: name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux 7Server (x86_64)
[line 92]: baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/UEKR4/x86_64/
[line 93]: gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
[line 94]: gpgcheck=1
[line 95]: enabled=1

File contains parsing errors 文件包含解析错误

以下节已添加到 /etc/yum.repos.d/public-yum-ol7.repo

[ol7_UEKR4]
 name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux $releasever ($basearch)
 baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR4/$basearch/
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
 gpgcheck=1
 enabled=1
on  it road.com

解决方案

新条目的每一行开头都有一个空格。
该文件如下所示:

[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
[ol7_UEKR3]
name=Latest Unbreakable Enterprise Kernel Release 3 for Oracle Linux $releasever ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR3/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
 [ol7_UEKR4]
 name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux $releasever ($basearch)
 baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR4/$basearch/
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
 gpgcheck=1
 enabled=1

请按照下面列出的步骤解决问题:

  1. 编辑 yum 存储库文件 /etc/yum.repos.d/public-yum-ol7.repo 。
# vi /etc/yum.repos.d/public-yum-ol7.repo
  1. 删除每行开头的空格:
[ol7_UEKR4]
name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux $releasever ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR4/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
  1. 保存并退出。

  2. 检查节是否正确保存:

# less /etc/yum.repos.d/public-yum-ol7.repo
  1. 继续运行“yum repolist”:
# yum repolist
日期:2020-09-17 00:14:16 来源:oir作者:oir