如何将CentOS 7.2升级至7.3且不升级到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).
- Edit the main CentOS-Base.repo file:
vi /etc/yum.repos.d/CentOS-Base.repo
For each repo section (
[base],[updates],[extras]):- Comment out the
mirrorlistline (add a#at the start) - Add a
baseurlline pointing to the 7.3 vault:
(Forbaseurl=http://vault.centos.org/7.3.1611/os/$basearch/updates, usehttp://vault.centos.org/7.3.1611/updates/$basearch/; forextras, usehttp://vault.centos.org/7.3.1611/extras/$basearch/) - Ensure
gpgcheck=1andgpgkeypoints to the correct key (usuallyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7which is valid for 7.3)
- Comment out the
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):
- Install the plugin:
yum install yum-plugin-versionlock
- 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 updatewithout 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

