您好,登錄后才能下訂單哦!
這篇文章以具體的示例來介紹一下從CentOS 7升級值CentOS 8的方法。
事前準備
最小化安裝CentOS 7,具體版本如下所示: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 ~]#
步驟1: 安裝epel-relase、yum-utils和rpmconf
執行命令:yum install yum-utils epel-release -y
執行日志如下所示:
...省略 ======================================================================================================================================== 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) ...省略
安裝命令:yum install rpmconf -y
安裝日志如下所示:
[root@liumiao ~]# yum install rpmconf -y ...省略 ======================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================== Installing: rpmconf noarch 0.3.4-1.el7 epel 21 k Transaction Summary ======================================================================================================================================== Install 1 Package ...省略 Complete!
[root@liumiao ~]#
步驟2: 安裝前檢查
檢查配置:rpmconf -a
執行日志如下所示,如有選擇直接使用缺省設定。
[root@liumiao ~]# rpmconf -a [root@liumiao ~]#
檢查葉節點:列出和其他RPM沒有依賴的軟件包
[root@liumiao ~]# package-cleanup --leaves Loaded plugins: fastestmirror libsysfs-2.1.0-16.el7.x86_64 [root@liumiao ~]#
檢查不再提供的軟件包:列出當前倉庫中不提供升級的軟件包信息
[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 ...省略 yum-plugin-fastestmirror-1.1.31-50.el7.noarch [root@liumiao ~]#
步驟3: 安裝dnf 并執行dnf update
CentOS 8使用dnf作為缺省的包管理工具,使用yum安裝自己的替代工具dnf并刪除自己。
安裝命令:yum install dnf -y
執行日志如下所示:
[root@liumiao ~]# yum install dnf -y ...省略 ======================================================================================================================================== 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) ...省略 [root@liumiao ~]#
清除yum:dnf -y remove yum yum-metadata-parser && rm -rf /etc/yum
執行日志如下所示:
[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 ~]#
就像使用yum update那樣使用dnf 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 ...省略 ======================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================== Upgrading: epel-release noarch 7-12 epel 15 k ...省略 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: ...省略 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 ~]#
使用dnf更新CentOS 8的包
執行日志如下所示:
[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 ~]#
更新epel倉庫
執行日志如下所示:
[root@liumiao ~]# dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm Extra Packages for Enterprise Linux 7 - x86_64 578 kB/s | 16 MB 00:28 CentOS-8 - Base 635 kB/s | 7.9 MB 00:12 CentOS-8 - Extras 1.7 kB/s | 2.1 kB 00:01 CentOS-8 - AppStream 1.3 MB/s | 6.3 MB 00:04 epel-release-latest-8.noarch.rpm 7.7 kB/s | 21 kB 00:02 Dependencies resolved. ======================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================== Upgrading: epel-release noarch 8-7.el8 @commandline 21 k Transaction Summary ======================================================================================================================================== Upgrade 1 Package Total size: 21 k Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Upgrading : epel-release-8-7.el8.noarch 1/2 Cleanup : epel-release-7-12.noarch 2/2 Verifying : epel-release-8-7.el8.noarch 1/2 Verifying : epel-release-7-12.noarch 2/2 Upgraded: epel-release-8-7.el8.noarch Complete! [root@liumiao ~]#
此時確認版本信息,已經發生了變化
[root@liumiao ~]# cat /etc/redhat-release CentOS Linux release 8.0.1905 (Core) [root@liumiao ~]#
步驟4: 刪除無用文件和CentOS 7的內核并安裝CentOS 8的內核
刪除無用的臨時文件:dnf clean all
執行日志如下所示:
[root@liumiao ~]# dnf clean all 62 files removed [root@liumiao ~]#
刪除CentOS 7的舊核: rpm -e `rpm -q kernel`
執行日志如下所示:
[root@liumiao ~]# rpm -e `rpm -q kernel` [root@liumiao ~]#
確認刪除沖突的包
[root@liumiao ~]# rpm -e --nodeps sysvinit-tools [root@liumiao ~]#
更新CentOS 8系統
[root@liumiao ~]# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync Extra Packages for Enterprise Linux 8 - x86_64 2.0 MB/s | 3.5 MB 00:01 CentOS-8 - Base 160 kB/s | 7.9 MB 00:50 CentOS-8 - AppStream 1.6 MB/s | 6.3 MB 00:03 CentOS-8 - Extras 950 B/s | 2.1 kB 00:02 Last metadata expiration check: 0:00:02 ago on Wed 20 Nov 2019 08:09:51 AM EST. Dependencies resolved. ======================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================== Upgrading: rpmconf noarch 1.0.20-1.el8 epel 26 k ...省略 Removed: deltarpm-3.6-3.el7.x86_64 libselinux-python-2.5-14.1.el7.x86_64 libxml2-python-2.9.1-6.el7_2.3.x86_64 newt-python-0.52.15-4.el7.x86_64 python-2.7.5-86.el7.x86_64 python-chardet-2.2.1-3.el7.noarch python-firewall-0.6.3-2.el7_7.2.noarch python-kitchen-1.1.1-5.el7.noarch python-libs-2.7.5-86.el7.x86_64 python-linux-procfs-0.4.11-4.el7.noarch python-schedutils-0.4-6.el7.x86_64 python-slip-0.4.0-4.el7.noarch python-slip-dbus-0.4.0-4.el7.noarch python-urlgrabber-3.10-9.el7.noarch python2-dnf-4.0.9.2-1.el7_6.noarch python2-hawkey-0.22.5-1.el7_6.x86_64 python2-libcomps-0.1.8-12.el7.x86_64 python2-libdnf-0.22.5-1.el7_6.x86_64 pyxattr-0.5.1-5.el7.x86_64 rpm-python-4.11.3-40.el7.x86_64 systemd-sysv-219-67.el7_7.2.x86_64 Complete! [root@liumiao ~]#
此時通過uname -a確認內核狀態,仍是3.10.
[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 8.0.1905 (Core) [root@liumiao ~]#
由于前文已經更新,此時如執行dnf -y install kernel-core會提示already updated,接下來更新一下CentOS 8的最小化安裝的相關package,執行如下命令即可:
[root@liumiao ~]# dnf -y groupupdate "Core" "Minimal Install" Last metadata expiration check: 0:13:34 ago on Wed 20 Nov 2019 08:09:51 AM EST. Dependencies resolved. ======================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================== Installing group/module packages: dnf-plugin-spacewalk noarch 2.8.5-11.module_el8.0.0+180+337688dc AppStream 24 k dnf-plugins-core noarch 4.0.2.2-3.el8 BaseOS 59 k ...省略 [root@liumiao ~]#
步驟5: 重啟系統
重啟之后即可確認內核和版本文件信息均已升至最新
[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 ~]#
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。