I usually install a virtual machine on VirtualBox by importing ova image files, such as CentOS7-base.ova downloaded from the Internet. The ova is CentOS 7.0 version, and the latest version is 7.7. The thing is the system upgrade:
# yum update
But the command quit unexpectedly!
Check after re-entering the system:
# uname -r 3.10.0-123.9.2.el7.x86_64 # cat /proc/version Linux version 3.10.0-123.9.2.el7.x86_64 ([email protected]) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Tue Oct 28 18:05:26 UTC 2014 # cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core)
It can be seen that the Linux release version number has been changed to 7.7, but the core is still the old version, and the yum update command fails to execute again, indicating that the system has not been successfully upgraded. It often takes a while to find two ways to upgrade from 7.0 to 7.7.
Method 1: Manually resolve the error after the upgrade failure and re-upgrade
After the yum update command exits abnormally, log in to the system again, and then execute:
Clean up the last failed command
# yum-complete-transaction --cleanup-only
View duplicate packages
# package-cleanup --dupes kbd-misc-1.15.5-10.el7.noarch kbd-misc-1.15.5-15.el7.noarch nss-tools-3.44.0-7.el7_7.x86_64 nss-tools-3.16.2-7.el7_0.x86_64 ... gzip-1.5-10.el7.x86_64 gzip-1.5-7.el7.x86_64
This command should have no output, but due to the failure of the last yum update command, a large number of new and old packages were repeated.
Remove duplicate packages
# package-cleanup --cleandupes ... Complete! Warning: Some duplicates were not removed because they are required by installed packages. You can try --cleandupes with --removenewestdupes, or review them with --dupes and remove manually.
Although this command deletes a lot of duplicate packages, the prompt is not completely cleared.
Try to upgrade again
# yum update ... --> Finished Dependency Resolution Error: Package: avahi-libs-0.6.31-13.el7.x86_64 (@anaconda) Requires: avahi = 0.6.31-13.el7 Removing: avahi-0.6.31-13.el7.x86_64 (@anaconda) avahi = 0.6.31-13.el7 Updated By: avahi-0.6.31-19.el7.x86_64 (base) avahi = 0.6.31-19.el7 Error: firewalld conflicts with 1:NetworkManager-0.9.9.1-28.git20140326.4dba720.el7_0.2.x86_64 Error: avahi-libs conflicts with avahi-0.6.31-19.el7.x86_64 You could try using --skip-broken to work around the problem ...
The upgrade still fails!
Delete the old package according to the error message above
# rpm -e avahi-libs-0.6.31-13.el7.x86_64 error: Failed dependencies: avahi-libs = 0.6.31-13.el7 is needed by (installed) avahi-0.6.31-13.el7.x86_64 avahi-libs = 0.6.31-13.el7 is needed by (installed) avahi-autoipd-0.6.31-13.el7.x86_64
The command failed because of dependencies. To do this, you also need to delete the dependencies:
# rpm -e avahi-libs-0.6.31-13.el7.x86_64 \ > avahi-0.6.31-13.el7.x86_64 \ > avahi-autoipd-0.6.31-13.el7.x86_64 error: Failed dependencies: avahi-autoipd is needed by (installed) NetworkManager-1:0.9.9.1-28.git20140326.4dba720.el7_0.2.x86_64
There are still other cascade dependencies, delete them together:
# rpm -e avahi-libs-0.6.31-13.el7.x86_64 \ > avahi-0.6.31-13.el7.x86_64 \ > avahi-autoipd-0.6.31-13.el7.x86_64 \ > NetworkManager-1:0.9.9.1-28.git20140326.4dba720.el7_0.2.x86_64 error: Failed dependencies: NetworkManager = 1:0.9.9.1-28.git20140326.4dba720.el7_0.2 is needed by (installed) NetworkManager-tui-1:0.9.9.1-28.git20140326.4dba720.el7_0.2.x86_64
Continue to delete:
# rpm -e avahi-libs-0.6.31-13.el7.x86_64 \ > avahi-0.6.31-13.el7.x86_64 \ > avahi-autoipd-0.6.31-13.el7.x86_64 \ > NetworkManager-1:0.9.9.1-28.git20140326.4dba720.el7_0.2.x86_64 \ > NetworkManager-tui-1:0.9.9.1-28.git20140326.4dba720.el7_0.2.x86_64
success!
Keep trying to upgrade
# yum update ... Replaced: grub2.x86_64 1:2.02-0.2.10.el7.centos.1 Complete!
success! After successful upgrade, please restart the system:
# reboot
View and delete duplicate packages again
# package-cleanup --dupes ... kbd-misc-1.15.5-10.el7.noarch kbd-misc-1.15.5-15.el7.noarch libdb-5.3.21-25.el7.x86_64 libdb-5.3.21-17.el7_0.1.x86_64 ... libteam-1.27-9.el7.x86_64 libteam-1.9-15.el7.x86_64
There are still some duplicate packages, delete them:
# package-cleanup --cleandupes ... --> Finished Dependency Resolution Error: Rpmdb checksum is invalid: pkg checksums: grub2-tools-1:2.02-0.2.10.el7.centos.1.x86_64 You could try using --skip-broken to work around the problem ...
Somehow I got an error, but the execution was successful again:
# package-cleanup --cleandupes ... Removed: audit-libs.x86_64 0:2.3.3-4.el7 bind-license.noarch 32:9.9.4-14.el7 device-mapper.x86_64 7:1.02.84-14.el7 device-mapper-event-libs.x86_64 7:1.02.84-14.el7 device-mapper-libs.x86_64 7:1.02.84 - 14 .el7 dracut.x86_64 0 : 033 - 161 .el7 e2fsprogs -libs.x86_64 0 : 1.42 . 9 - 4 .el7 kbd-misc.noarch 0 : 1.15 . 5 - 10 .el7 libcom_err.x86_64 0 : 1.42 . 9 - 4 .el7 libcurl.x86_64 0 : 7.29 . 0 - 19 .el7 libdb.x86_64 0: 5.3 . 21 - 17 .el7_0. 1 libss.x86_64 0 : 1.42 . 9 - 4 .el7 libteam.x86_64 0 : 1.9 - 15 .el7 systemd.x86_64 0 : 208 - 11 .el7_0. 4 systemd-libs.x86_64 0 : 208 - 11 .el7_0. 4 Complete !
Check again for duplicate packages:
# package-cleanup --dupes
There are no duplicate packages.
Restart the system and check the new version number again
# reboot
# uname -r 3.10.0-1062.18.1.el7.x86_64
# cat /proc/version
Linux version 3.10.0-1062.18.1.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Mar 17 23:49:17 UTC 2020
# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
Completely correct! So far the upgrade is successful!
Method 2: From 7.0 to 7.5 to 7.7 version
If you have executed the yum update command and failed, you can only use the above method to solve it. This method is applicable to newly installed systems.
Upgrade from 7.0 to 7.5
The yum update command upgrades to the latest version by default, but we can modify the configuration file to upgrade it to the specified version.
Check for updates
# yum list centos-release
...
Installed Packages
centos-release.x86_64 7-0.1406.el7.centos.2.5 @updates
Available Packages
centos-release.x86_64 7-7.1908.0.el7.centos base
This command shows that the current version is 7.0 and can be upgraded to version 7.7 (but we know that the upgrade will report an error).
Modify the CentOS-Base.repo file to point to the 7.5 version library
Comment out the mirrorlist in the CentOS-Base.repo file, and add the corresponding baseurl, the other unchanged, as follows:
# cat /etc/yum.repos.d/CentOS-Base.repo ... [base]
... #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=http://vault.centos.org/7.5.1804/os/$basearch/ ...
[updates]
... #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ baseurl=http://vault.centos.org/7.5.1804/updates/$basearch/ ...
[extras] ...
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ baseurl=http://vault.centos.org/7.5.1804/extras/$basearch/ ...
[centosplus]
... #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ baseurl = http: // vault.centos.org/7.5.1804/centosplus/$basearch/ ...
Empty the cache
After modifying the configuration file, we need to clear the cache:
# yum clean all
Check for updates again
# yum list centos-release Installed Packages centos-release.x86_64 7-0.1406.el7.centos.2.5 @updates Available Packages centos-release.x86_64 7-5.1804.5.el7.centos updates
It can be seen that if you upgrade, you will upgrade to version 7.5.
Upgrade to version 7.5
# yum update
After the upgrade is successful, please reboot to restart the system.
Upgrade from 7.5 to 7.7
Restore the above CentOS-Base.repo file, clear the cache, and then execute yum update.