获取 CentOS 8 系统的正确存储库

获取 CentOS 8 系统的正确存储库

抱歉,如果这是一个非常基本的问题,但我从来没有真正需要深入研究 yum/dnf 。

历史:当更新停止时,我重新构建了一台运行 Centos 7 的服务器。我没有太注意构建时使用的内容,只是下载了网络安装并使用它来加载我需要的所有内容。

我确实注意到没有发生任何更新,并且发现一些内容表明基本发行版中缺少更新流。我按照说明添加了该内容,并且有很多更新可用。

我还从完整的 DVD 映像加载了笔记本电脑上的虚拟机。

现在:在我的服务器上没有看到任何更新。已经有一段时间没有了。这看起来很奇怪。它似乎也是 8.0,而 VM 版本是 8.2,并且确实有更新。

当我列出存储库时,略有不同;

服务器:

# yum repolist enabled
repo id                                               repo name
appstream                                             CentOS Stream 8 - AppStream
baseos                                                CentOS Stream 8 - BaseOS
epel                                                  Extra Packages for Enterprise Linux 8 - x86_64
epel-modular                                          Extra Packages for Enterprise Linux Modular 8 - x86_64
extras                                                CentOS Stream 8 - Extras

虚拟机:

# yum repolist
repo id                                                   repo name
AppStream                                                 CentOS-8 - AppStream
BaseOS                                                    CentOS-8 - Base
extras                                                    CentOS-8 - Extras
google-chrome                                             google-chrome

虚拟机不需要 epel 存储库,所以没关系。但基础仓库的列表是不同的......

谁能告诉我如何为我的服务器安装正确的存储库??? (重建不是一个选择 - 升级后需要很长时间才能让一切恢复正常)。


尝试更新,我总是看到这个:

# dnf update
Last metadata expiration check: 2:20:32 ago on Sun 29 Nov 2020 11:18:48 AM PST.
Dependencies resolved.
Nothing to do.
Complete!

日志输出:

2020-11-29T21:39:19Z DDEBUG Command: dnf update 
2020-11-29T21:39:19Z DDEBUG Installroot: /
2020-11-29T21:39:19Z DDEBUG Releasever: 8
2020-11-29T21:39:19Z DEBUG cachedir: /var/cache/dnf
2020-11-29T21:39:19Z DDEBUG Base command: update
2020-11-29T21:39:19Z DDEBUG Extra commands: ['update']
2020-11-29T21:39:19Z DEBUG User-Agent: constructed: 'libdnf (CentOS Stream 8; generic; Linux.x86_64)'
2020-11-29T21:39:19Z DEBUG repo: using cache for: appstream
2020-11-29T21:39:19Z DEBUG appstream: using metadata from Thu 29 Oct 2020 06:52:17 PM PDT.
2020-11-29T21:39:19Z DEBUG repo: using cache for: baseos
2020-11-29T21:39:19Z DEBUG baseos: using metadata from Thu 29 Oct 2020 06:52:12 PM PDT.
2020-11-29T21:39:19Z DEBUG repo: using cache for: extras
2020-11-29T21:39:19Z DEBUG extras: using metadata from Fri 10 Jul 2020 07:19:28 AM PDT.
2020-11-29T21:39:20Z DEBUG repo: using cache for: epel-modular
2020-11-29T21:39:20Z DEBUG epel-modular: using metadata from Mon 16 Nov 2020 06:30:02 PM PST.
2020-11-29T21:39:20Z DEBUG repo: using cache for: epel
2020-11-29T21:39:20Z DEBUG epel: using metadata from Sat 28 Nov 2020 05:04:32 PM PST.
2020-11-29T21:39:20Z INFO Last metadata expiration check: 2:20:32 ago on Sun 29 Nov 2020 11:18:48 AM PST.
2020-11-29T21:39:20Z DDEBUG timer: sack setup: 420 ms
2020-11-29T21:39:20Z DEBUG Completion plugin: Generating completion cache...
2020-11-29T21:39:20Z DEBUG --> Starting dependency resolution
2020-11-29T21:39:20Z DEBUG --> Finished dependency resolution
2020-11-29T21:39:20Z DDEBUG timer: depsolve: 108 ms
2020-11-29T21:39:20Z INFO Dependencies resolved.
2020-11-29T21:39:20Z INFO Nothing to do.
2020-11-29T21:39:20Z INFO Complete!
2020-11-29T21:39:20Z DDEBUG Cleaning up.
# cat /etc/*-release
CentOS Stream release 8
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
# grep -rH enabled=1 /etc/yum.repos.d/*
/etc/yum.repos.d/CentOS-Stream-AppStream.repo:enabled=1
/etc/yum.repos.d/CentOS-Stream-BaseOS.repo:enabled=1
/etc/yum.repos.d/CentOS-Stream-Extras.repo:enabled=1
/etc/yum.repos.d/epel-modular.repo:enabled=1
/etc/yum.repos.d/epel.repo:enabled=1

请注意这与我的虚拟机有何不同:

# grep -rH enabled=1 /etc/yum.repos.d/*
/etc/yum.repos.d/CentOS-AppStream.repo:enabled=1
/etc/yum.repos.d/CentOS-Base.repo:enabled=1
/etc/yum.repos.d/CentOS-Extras.repo:enabled=1
/etc/yum.repos.d/epel-modular.repo:enabled=1
/etc/yum.repos.d/epel.repo:enabled=1
/etc/yum.repos.d/google-chrome.repo:enabled=1

镜像列表

在虚拟机上:

# find /var -name mirrorlist 
/var/cache/PackageKit/8/metadata/AppStream-8-x86_64/mirrorlist
/var/cache/PackageKit/8/metadata/BaseOS-8-x86_64/mirrorlist
/var/cache/PackageKit/8/metadata/extras-8-x86_64/mirrorlist
/var/cache/dnf/AppStream-a520ed22b0a8a736/mirrorlist
/var/cache/dnf/BaseOS-929b586ef1f72f69/mirrorlist
/var/cache/dnf/extras-2770d521ba03e231/mirrorlist

# find /var -name mirrorlist -exec cat {} \;
http://mirror.centos.org/centos/8/AppStream/x86_64/os/
http://mirror.centos.org/centos/8/BaseOS/x86_64/os/
http://mirror.centos.org/centos/8/extras/x86_64/os/
http://mirror.centos.org/centos/8/AppStream/x86_64/os/
http://mirror.centos.org/centos/8/BaseOS/x86_64/os/
http://mirror.centos.org/centos/8/extras/x86_64/os/

在服务器上:

# find /var -name mirrorlist 
/var/cache/PackageKit/8/metadata/AppStream-8-x86_64/mirrorlist
/var/cache/PackageKit/8/metadata/BaseOS-8-x86_64/mirrorlist
/var/cache/PackageKit/8/metadata/extras-8-x86_64/mirrorlist
/var/cache/dnf/appstream-773ef6463612e8e2/mirrorlist
/var/cache/dnf/baseos-055ffcb2ec25a27f/mirrorlist
/var/cache/dnf/extras-9705a089504ff150/mirrorlist

# find /var -name mirrorlist -exec cat {} \;
http://mirror.cc.columbia.edu/pub/linux/centos/8.2.2004/AppStream/x86_64/os/
http://repo.miserver.it.umich.edu/centos/8.2.2004/AppStream/x86_64/os/
http://mirror.mojohost.com/centos/8.2.2004/AppStream/x86_64/os/
http://mirror.genesisadaptive.com/centos/8.2.2004/AppStream/x86_64/os/
http://mirror.san.fastserv.com/pub/linux/centos/8.2.2004/AppStream/x86_64/os/
http://mirrors.usinternet.com/centos/8.2.2004/AppStream/x86_64/os/
http://repos.lax.layerhost.com/centos/8.2.2004/AppStream/x86_64/os/
http://ewr.edge.kernel.org/centos/8.2.2004/AppStream/x86_64/os/
http://repo1.dal.innoscale.net/centos/8.2.2004/AppStream/x86_64/os/
http://mirrors.xtom.com/centos/8.2.2004/AppStream/x86_64/os/
http://mirror.nodesdirect.com/centos/8.2.2004/BaseOS/x86_64/os/
http://distro.ibiblio.org/centos/8.2.2004/BaseOS/x86_64/os/
http://mirror.linux.duke.edu/pub/centos/8.2.2004/BaseOS/x86_64/os/
http://mirror.mojohost.com/centos/8.2.2004/BaseOS/x86_64/os/
http://mirror.sfo12.us.leaseweb.net/centos/8.2.2004/BaseOS/x86_64/os/
http://mirror.sesp.northwestern.edu/centos/8.2.2004/BaseOS/x86_64/os/
http://mirror.trouble-free.net/centos/8.2.2004/BaseOS/x86_64/os/
http://ftp.osuosl.org/pub/centos/8.2.2004/BaseOS/x86_64/os/
http://mirror.web-ster.com/centos/8.2.2004/BaseOS/x86_64/os/
http://mirror.rackspace.com/CentOS/8.2.2004/BaseOS/x86_64/os/
http://mirror.ette.biz/centos/8.2.2004/extras/x86_64/os/
http://mirror.wdc1.us.leaseweb.net/centos/8.2.2004/extras/x86_64/os/
http://mirror.rackspace.com/CentOS/8.2.2004/extras/x86_64/os/
http://mirror.vcu.edu/pub/gnu_linux/centos/8.2.2004/extras/x86_64/os/
http://mirrors.raystedman.org/centos/8.2.2004/extras/x86_64/os/
http://ftp.osuosl.org/pub/centos/8.2.2004/extras/x86_64/os/
http://centos.mirror.constant.com/8.2.2004/extras/x86_64/os/
http://us.mirror.nsec.pt/centos/8.2.2004/extras/x86_64/os/
http://mirror.oss.ou.edu/centos/8.2.2004/extras/x86_64/os/
http://mirror.sesp.northwestern.edu/centos/8.2.2004/extras/x86_64/os/
http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/
http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/
http://mirror.centos.org/centos/8-stream/extras/x86_64/os/

所以完全不同...


.repo 文件内容(仅列出 Centos 的,不列出 epel):

/etc/yum.repos.d/CentOS-Stream-AppStream.repo:

# CentOS-Stream-AppStream.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

[appstream]
name=CentOS Stream $releasever - AppStream
mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-----------------------------------------------------

/etc/yum.repos.d/CentOS-Stream-BaseOS.repo:

# CentOS-Stream-BaseOS.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

[baseos]
name=CentOS Stream $releasever - BaseOS
mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-----------------------------------------------------

/etc/yum.repos.d/CentOS-Stream-Debuginfo.repo:

# CentOS-Stream-Debuginfo.repo
#
# All debug packages are merged into a single repo, split by basearch, and are
# not signed.

[debuginfo]
name=CentOS Stream $releasever - Debuginfo
baseurl=http://debuginfo.centos.org/$stream/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-----------------------------------------------------

/etc/yum.repos.d/CentOS-Stream-Extras.repo:

# CentOS-Stream-Extras.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

[extras]
name=CentOS Stream $releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/extras/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-----------------------------------------------------

/etc/yum.repos.d/CentOS-Stream-HighAvailability.repo:

# CentOS-Stream-HighAvailability.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

[ha]
name=CentOS Stream $releasever - HighAvailability
mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=HighAvailability&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/HighAvailability/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-----------------------------------------------------

/etc/yum.repos.d/CentOS-Stream-Media.repo:

# CentOS-Stream-Media.repo
#
# You can use this repo to install items directly off the installation media.
# Verify your mount point matches one of the below file:// paths.

[media-baseos]
name=CentOS Stream $releasever - Media - BaseOS
baseurl=file:///media/CentOS/BaseOS
        file:///media/cdrom/BaseOS
        file:///media/cdrecorder/BaseOS
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[media-appstream]
name=CentOS Stream $releasever - Media - AppStream
baseurl=file:///media/CentOS/AppStream
        file:///media/cdrom/AppStream
        file:///media/cdrecorder/AppStream
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-----------------------------------------------------

/etc/yum.repos.d/CentOS-Stream-Plus.repo:

# CentOS-Stream-Plus.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

[plus]
name=CentOS Stream $releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-----------------------------------------------------

/etc/yum.repos.d/CentOS-Stream-PowerTools.repo:

# CentOS-Stream-PowerTools.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

[powertools]
name=CentOS Stream $releasever - PowerTools
mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=PowerTools&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-----------------------------------------------------

/etc/yum.repos.d/CentOS-Stream-RealTime.repo:

# CentOS-Stream-RealTime.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

[rt]
name=CentOS Stream $releasever - RealTime
mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=RT&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/RT/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-----------------------------------------------------

答案1

来自 RHEL 8 文档:

RHEL 8 内容通过两个主要存储库分发:BaseOS 和 AppStream。

BaseOS BaseOS 存储库中的内容旨在提供底层操作系统功能的核心集,为所有安装提供基础。此内容以 RPM 格式提供,并受与之前版本的 Red Hat Enterprise Linux 类似的支持条款的约束。

AppStream 存储库中的 AppStream 内容包括其他用户空间应用程序、运行时语言和数据库,以支持各种工作负载和用例。 AppStream 中的内容以两种格式之一提供 - 熟悉的 RPM 格式和称为模块的 RPM 格式扩展。

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/installing_managing_and_removing_user-space_components/using-appstream_using-appstream了解完整详情。

答案2

一个快速的解决方案是附加 $releasever对于-stream每个无法获取镜像列表的 repo,例如:

mirrorlist.centos.org/?release=$releasever-stream ...

就像这样,

[BaseOS]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever-stream&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$stream/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

答案3

您的服务器正在运行“Centos 8 Stream”。您的虚拟机正在运行传统的“Centos 8”。

你问有什么区别? Centos 传统上是下游RHEL,从而形成稳定的、具有生产能力的操作系统。此流程限制了其他开发人员贡献有利于 RHEL 产品的代码的能力。通过迁移 CentOS上游通过 RHEL,红帽可以更轻松地允许这些贡献,这些贡献将向下流动并最终使 RHEL 受益。 CentOS Stream 现在位于 Fedora 和 RHEL 之间,对传统 CentOS 产品的支持很快就会结束。

来自维基百科:

2020 年 12 月,红帽和 CentOS 董事会宣布 CentOS Linux 开发将于 2021 年底结束。不过,CentOS 项目将继续生产相关的持续交付发行版 CentOS Stream。

生命结束日期:

CentOS 8 的所有更新将于 2021 年 12 月 31 日结束。但是,CentOS 7 将继续接收维护更新,直到 2024 年 6 月 30 日。

https://wiki.centos.org/About/Product

创建备用下游发行版的项目正在进行中(例如 Rocky Linux -https://rockylinux.org/)用于生产环境。然而,在它们完成之前,您只有几个选择:

  1. 使用 CentOS 流
  2. 迁移到不同的发行版
  3. 红帽现在通过“免费红帽开发者订阅”免费提供一定数量(也许是 8 个?)的 RHEL 实例。 (https://developers.redhat.com/articles/faqs-no-cost-red-hat-enterprise-linux

这可能对某些用户有用,但我相信很多人都坚持使用 Rocky Linux,希望它能成为传统 CentOS 的直接替代品。

相关内容