如何通过 yum update 坚持使用 CentOS 7 上的一个版本?

如何通过 yum update 坚持使用 CentOS 7 上的一个版本?

每当我这样做时yum update,我都会自动升级到最新版本。我需要坚持使用 CentOS 的一个版本(即 7.3)。

也尝试过yum --releasever=7.3 update,我遇到了以下错误,但能够做到yum update

[root@myvm ~]# yum --releasever=7.3 update

Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager

 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7.3/x86_64

答案1

编辑/etc/yum.repos.d/CentOS-Base.repo指向vault.centos.org

在每个启用的存储库部分中,将baseurl, 例如更改为:

baseurl=http://vault.centos.org/7.3.1611/os/$basearch 

baseurl=http://vault.centos.org/7.3.1611/updates/$basearch

注释掉或干脆删除mirrorlist您更改 .txt 文件的每个节中的指令baseurl

extras这对于、centosplus和存储库的作用类似fasttrack

答案2

当 CentOS 7.4.1708 的 Docker 映像开始从 CentOS 7.5.1804 获取新软件包时,我遇到了相关问题,并且无法再找到之前为 7.4 发布的更新。我通过调整存储库配置解决了这个问题sed

sed -e '/mirrorlist=.*/d' \
    -e 's/#baseurl=/baseurl=/' \
    -e "s/\$releasever/7.4.1708/g" \
    -e "s/mirror.centos.org\\/centos/vault.centos.org/g" \
    -i /etc/yum.repos.d/CentOS-Base.repo

这是基于 JRFerguson 的答案,尽管具有不同的基本 URL:

  1. 删除mirrorlist=线条。
  2. 取消注释这些baseurl=行。
  3. 将所需的发行版本明确放入基本 URL(和存储库名称)中。

例如,这个默认配置:

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

变成:

[base]
name=CentOS-7.4.1708 - Base
baseurl=http://vault.centos.org/7.4.1708/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

但这只是一个临时解决方法,因为旧软件包会在新版本发布几周后从镜像中删除。在发布新的 Docker 基础镜像之前,7.4 的那些内容已被删除。

答案3

yum install yum-utils
yum-config-manager --disable CentOS-7*
yum-config-manager --enable CentOS-7.3*
yum update  # update to the requested 7.3 ver.

或者如果您有多个启用的存储库,包括所需的 7.3 版本:

yum update --disablerepo=* --enablerepo=\*7.3\*

答案4

我遇到了一个问题,服务器是由 iso DVD Redhat 配置来安装 RPM 的,我的解决方案是/etc/yum.repos.d/rhel7.5DVD.repo使用以下命令忽略此文件:

mv /etc/yum.repos.d/rhel7.5DVD.repo /etc/yum.repos.d/rhel7.5DVD.repo.tmp

相关内容