How to Upgrade CentOS7 to CentOS8 of Detailed Steps
- 2021-07-09 09:48:40
- OfStack
This article introduces the method of upgrading the value CentOS 8 from CentOS 7 under 1 with concrete examples.
Prepare beforehand
Minimize the installation of CentOS 7 with the following version: 7.6. 1810
[root@liumiao ~]# uname -a
Linux devops 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@liumiao ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@liumiao ~]#
Step 1: Install epel-relase, yum-utils, and rpmconf
Execute a command:
yum install yum-utils epel-release -y
The execution log looks like this:
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
yum-utils noarch 1.1.31-52.el7 base 121 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
========================================================================================================================================
Install 2 Packages (+3 Dependent packages)
... Omission
Installation command:
yum install rpmconf -y
The installation log looks like this:
[root@liumiao ~]# yum install rpmconf -y
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
rpmconf noarch 0.3.4-1.el7 epel 21 k
Transaction Summary
========================================================================================================================================
Install 1 Package
... Omission
Complete!
[root@liumiao ~]#
Step 2: Check before installation
Check configuration: rpmconf-a
The execution log is shown below. If you choose, use the default settings directly.
[root@liumiao ~]# rpmconf -a
[root@liumiao ~]#
Check leaf nodes: List packages that are not dependent on RPM
[root@liumiao ~]# package-cleanup --leaves
Loaded plugins: fastestmirror
libsysfs-2.1.0-16.el7.x86_64
[root@liumiao ~]#
Check for packages that are no longer available: List packages that are not available for upgrades in the current repository
[root@liumiao ~]# package-cleanup --orphans
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* epel: hkg.mirror.rackspace.com
* extras: mirror.bit.edu.cn
* updates: ap.stykers.moe
GeoIP-1.5.0-13.el7.x86_64
... Omission
yum-plugin-fastestmirror-1.1.31-50.el7.noarch
[root@liumiao ~]#
Step 3: Install dnf and execute dnf update
CentOS 8 uses dnf as the default package management tool, uses yum to install its own replacement, dnf, and removes itself.
Installation command:
yum install dnf -y
The execution log looks like this:
[root@liumiao ~]# yum install dnf -y
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
dnf noarch 4.0.9.2-1.el7_6 extras 357 k
Installing for dependencies:
deltarpm x86_64 3.6-3.el7 base 82 k
dnf-data noarch 4.0.9.2-1.el7_6 extras 51 k
libcomps x86_64 0.1.8-12.el7 extras 75 k
libdnf x86_64 0.22.5-1.el7_6 extras 533 k
libmodulemd x86_64 1.6.3-1.el7 extras 141 k
librepo x86_64 1.8.1-7.el7 base 81 k
libreport-filesystem x86_64 2.1.11-43.el7.centos base 40 k
libsolv x86_64 0.6.34-4.el7 base 329 k
libyaml x86_64 0.1.4-11.el7_0 base 55 k
python-enum34 noarch 1.0.4-1.el7 base 52 k
python2-dnf noarch 4.0.9.2-1.el7_6 extras 414 k
python2-hawkey x86_64 0.22.5-1.el7_6 extras 68 k
python2-libcomps x86_64 0.1.8-12.el7 extras 47 k
python2-libdnf x86_64 0.22.5-1.el7_6 extras 608 k
Transaction Summary
========================================================================================================================================
Install 1 Package (+14 Dependent packages)
... Omission
[root@liumiao ~]#
Clear yum:
dnf -y remove yum yum-metadata-parser && rm -rf /etc/yum
The execution log looks like this:
[root@liumiao ~]# dnf -y remove yum yum-metadata-parser
Dependencies resolved.
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Removing:
yum noarch 3.4.3-161.el7.centos @System 5.6 M
yum-metadata-parser x86_64 1.1.4-10.el7 @System 57 k
Removing dependent packages:
yum-plugin-fastestmirror noarch 1.1.31-50.el7 @System 53 k
yum-utils noarch 1.1.31-52.el7 @System 337 k
Transaction Summary
========================================================================================================================================
Remove 4 Packages
Freed space: 6.0 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Erasing : yum-utils-1.1.31-52.el7.noarch 1/4
Erasing : yum-plugin-fastestmirror-1.1.31-50.el7.noarch 2/4
Erasing : yum-3.4.3-161.el7.centos.noarch 3/4
Erasing : yum-metadata-parser-1.1.4-10.el7.x86_64 4/4
Verifying : yum-3.4.3-161.el7.centos.noarch 1/4
Verifying : yum-metadata-parser-1.1.4-10.el7.x86_64 2/4
Verifying : yum-plugin-fastestmirror-1.1.31-50.el7.noarch 3/4
Verifying : yum-utils-1.1.31-52.el7.noarch 4/4
Removed:
yum-3.4.3-161.el7.centos.noarch yum-metadata-parser-1.1.4-10.el7.x86_64 yum-plugin-fastestmirror-1.1.31-50.el7.noarch
yum-utils-1.1.31-52.el7.noarch
Complete!
[root@liumiao ~]# ls /etc/yum
pluginconf.d protected.d vars
[root@liumiao ~]# rm -rf /etc/yum
[root@liumiao ~]#
Update with dnf update just as with yum update.
[root@liumiao ~]# dnf upgrade
Extra Packages for Enterprise Linux 7 - x86_64 5.6 MB/s | 16 MB 00:02
CentOS-7 - Base 3.5 MB/s | 10 MB 00:02
CentOS-7 - Updates 2.9 MB/s | 5.4 MB 00:01
CentOS-7 - Extras 40 kB/s | 251 kB 00:06
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Upgrading:
epel-release noarch 7-12 epel 15 k
... Omission
tzdata noarch 2019c-1.el7 updates 493 k
Installing dependencies:
bind-export-libs x86_64 32:9.11.4-9.P2.el7 base 1.1 M
geoipupdate x86_64 2.5.0-1.el7 base 35 k
kernel x86_64 3.10.0-1062.4.3.el7 updates 50 M
Transaction Summary
========================================================================================================================================
Install 3 Packages
Upgrade 164 Packages
Total download size: 259 M
Is this ok [y/N]: y
Downloading Packages:
... Omission
Installed:
bind-export-libs-32:9.11.4-9.P2.el7.x86_64 geoipupdate-2.5.0-1.el7.x86_64 kernel-3.10.0-1062.4.3.el7.x86_64
Complete!
[root@liumiao ~]#
Update packages for CentOS 8 with dnf
The execution log looks like this:
[root@liumiao ~]# dnf -y upgrade http://mirror.bytemark.co.uk/centos/8/BaseOS/x86_64/os/Packages/centos-release-8.0-0.1905.0.9.el8.x86_64.rpm
Extra Packages for Enterprise Linux 7 - x86_64 4.3 MB/s | 16 MB 00:03
Last metadata expiration check: 0:00:01 ago on Wed 20 Nov 2019 07:58:07 AM EST.
centos-release-8.0-0.1905.0.9.el8.x86_64.rpm 13 kB/s | 26 kB 00:01
Dependencies resolved.
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Upgrading:
centos-release x86_64 8.0-0.1905.0.9.el8 @commandline 26 k
Transaction Summary
========================================================================================================================================
Upgrade 1 Package
Total size: 26 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : centos-release-8.0-0.1905.0.9.el8.x86_64 1/2
Cleanup : centos-release-7-7.1908.0.el7.centos.x86_64 2/2
Verifying : centos-release-8.0-0.1905.0.9.el8.x86_64 1/2
Verifying : centos-release-7-7.1908.0.el7.centos.x86_64 2/2
Upgraded:
centos-release-8.0-0.1905.0.9.el8.x86_64
Complete!
[root@liumiao ~]#
Update the epel repository
The execution log looks like this:
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
yum-utils noarch 1.1.31-52.el7 base 121 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
========================================================================================================================================
Install 2 Packages (+3 Dependent packages)
... Omission
0
At this point, confirm that the version information has changed
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
yum-utils noarch 1.1.31-52.el7 base 121 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
========================================================================================================================================
Install 2 Packages (+3 Dependent packages)
... Omission
1
Step 4: Remove the useless files and the kernel of CentOS 7 and install the kernel of CentOS 8
Delete useless temporary files: dnf clean all
The execution log looks like this:
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
yum-utils noarch 1.1.31-52.el7 base 121 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
========================================================================================================================================
Install 2 Packages (+3 Dependent packages)
... Omission
2
Remove the old core of CentOS 7: rpm-e ` rpm-q kernel `
The execution log looks like this:
[root@liumiao ~]# rpm -e `rpm -q kernel`
[root@liumiao ~]#
Confirm deletion of conflicting packages
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
yum-utils noarch 1.1.31-52.el7 base 121 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
========================================================================================================================================
Install 2 Packages (+3 Dependent packages)
... Omission
4
Update CentOS 8 System
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
yum-utils noarch 1.1.31-52.el7 base 121 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
========================================================================================================================================
Install 2 Packages (+3 Dependent packages)
... Omission
5
At this point, the kernel status is confirmed through uname-a, which is still 3.10.
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
yum-utils noarch 1.1.31-52.el7 base 121 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
========================================================================================================================================
Install 2 Packages (+3 Dependent packages)
... Omission
6
Since the above has been updated, if dnf-y install kernel-core is executed at this time, already updated will be prompted. Next, update the relevant package of the minimized installation of CentOS 8 under 1, and execute the following command:
... Omission
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k
yum-utils noarch 1.1.31-52.el7 base 121 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
========================================================================================================================================
Install 2 Packages (+3 Dependent packages)
... Omission
7
Step 5: Restart the system
After restarting, you can confirm that the kernel and version file information have been upgraded to the latest
[root@liumiao ~]# uname -a
Linux devops 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@liumiao ~]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
[root@liumiao ~]#