You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将CentOS 7.2升级至7.3且不升级到7.4?

Upgrading CentOS 7.2 to 7.3 (Avoiding 7.4)

Alright, let's walk through how to safely upgrade your CentOS 7.2 system to 7.3 without accidentally bumping up to 7.4. This requires tweaking your yum repositories and locking down versions to prevent unwanted upgrades later.

Step 1: Back Up Your System

Don't skip this! Upgrades can go sideways, so take a full backup of critical directories (like /etc, /var, /home) using tar, or use a VM snapshot if you're running on virtualized hardware. Example backup command for /etc:

tar -czf etc_backup_$(date +%Y%m%d).tar.gz /etc

Step 2: Modify YUM Repositories to Point to CentOS 7.3

By default, CentOS's official repos point to the latest 7.x release. We need to redirect them to the 7.3 vault (since old releases are moved to vault.centos.org).

  1. Edit the main CentOS-Base.repo file:
vi /etc/yum.repos.d/CentOS-Base.repo
  1. For each repo section ([base], [updates], [extras]):

    • Comment out the mirrorlist line (add a # at the start)
    • Add a baseurl line pointing to the 7.3 vault:
      baseurl=http://vault.centos.org/7.3.1611/os/$basearch/
      
      (For updates, use http://vault.centos.org/7.3.1611/updates/$basearch/; for extras, use http://vault.centos.org/7.3.1611/extras/$basearch/)
    • Ensure gpgcheck=1 and gpgkey points to the correct key (usually file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 which is valid for 7.3)
  2. Save and exit the file.

Step 3: Clean YUM Cache and Refresh Repos

Clear out old cached repo data to avoid conflicts:

yum clean all
rm -rf /var/cache/yum
yum makecache

Step 4: Perform the Upgrade to 7.3

Now run the upgrade command. To ensure only official CentOS repos are used (and skip third-party repos that might pull newer packages), use:

yum update --disablerepo=* --enablerepo=base,updates,extras

You'll see packages being upgraded to 7.3 versions. Confirm the prompts to proceed.

Step 5: Lock the Version to Prevent Accidental Upgrade to 7.4

To make sure your system doesn't automatically jump to 7.4 later, install the yum-plugin-versionlock and lock the centos-release package (this controls which repo versions yum uses):

  1. Install the plugin:
yum install yum-plugin-versionlock
  1. Lock the centos-release package:
yum versionlock add centos-release

This will prevent yum from updating the release package, which would switch your repos back to the latest 7.x version.

Verify the Upgrade

Once the upgrade finishes, check your CentOS version to confirm you're on 7.3:

cat /etc/redhat-release

You should see output like:

CentOS Linux release 7.3.1611 (Core)

Key Recommendations

  • If you have third-party repos (like EPEL), you'll need to adjust them to point to 7.3 as well, or disable them during upgrades to avoid pulling 7.4 packages.
  • Avoid running yum update without specifying repos unless you're sure your version locks are in place.
  • Keep in mind that CentOS 7.3 is end-of-life, so critical security fixes are no longer provided. Only stay on 7.3 if you have strict compatibility requirements—otherwise, plan a controlled upgrade to a supported release when possible.

内容的提问来源于stack exchange,提问作者karthik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:02:14