之路 on it Road.com

将包管理器从 YUM 升级到 DNF:

在 CentOS 8(默认的 Linux 包管理器)中,yum 已被 dnf(Dandified Yum)取代。

因此,在升级我们的 CentOS 7 服务器之前,我们必须切换到 dnf 包管理器。

使用 yum 命令安装 dnf 包管理器。

[root@centos-7-server ~]# yum install -y dnf

不再需要 yum,因此我们使用 dnf 命令删除 yum 包管理器。

[root@centos-7-server ~]# dnf remove -y yum yum-metadata-parser

删除任何遗留的 yum 配置。

[root@centos-7-server ~]# rm -Rf /etc/yum

为 dnf 存储库构建缓存。

[root@centos-7-server ~]# dnf makecache
Extra Packages for Enterprise Linux 7 - x86_64   54 kB/s |  16 MB     05:08
CentOS-7 - Base                                 991 kB/s |  10 MB     00:10
CentOS-7 - Updates                              1.2 MB/s | 7.0 MB     00:05
CentOS-7 - Extras                               1.5 MB/s | 251 kB     00:00
Metadata cache created.

将 CentOS 7 服务器升级到最新的稳定版本:

我们的 Linux 服务器现在可以升级到 CentOS 8.

执行以下命令将软件包更新到最新的 CentOS 7 版本。

[root@centos-7-server ~]# dnf upgrade -y

删除重复/未使用的包和配置:

使用 rpmconf 命令查找并删除冲突的配置文件(.rpmnew、.rpmsave 和 .rpmorigfiles)。
这些文件是在安装已安装软件包的新版本期间创建的。

[root@centos-7-server ~]# rpmconf -a
Configuration file `/etc/nsswitch.conf'
-rw-r--r--. 1 root root 1746 Dec 22  2018 /etc/nsswitch.conf
-rw-r--r--. 1 root root 1938 Aug  7 04:00 /etc/nsswitch.conf.rpmnew
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      M     : merge configuration files
      Z     : background this process to examine the situation
      S     : skip this file
 The default action is to keep your current version.
*** aliases (Y/I/N/O/D/Z/S) [default=N] ?
Your choice:

列出任何其他已安装软件包不需要的软件包。

[root@centos-7-server ~]# package-cleanup --leaves
Loaded plugins: fastestmirror
bind-libs-lite-9.11.4-9.P2.el7.x86_64
libsysfs-2.1.0-16.el7.x86_64

列出当前配置的 yum 存储库中不可用的旧的或者重复的软件包。

[root@centos-7-server ~]# package-cleanup --orphans
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ges.net.pk
 * epel: my.fedora.ipserverone.com
 * extras: mirrors.ges.net.pk
 * updates: repo.isra.edu.pk
kernel-3.10.0-957.el7.x86_64

卸载上述 package-cleanup 命令列出的所有软件包。

[root@centos-7-server ~]# yum remove -y \
> bind-libs-lite-9.11.4-9.P2.el7.x86_64 \
> libsysfs-2.1.0-16.el7.x86_64 \
> kernel-3.10.0-957.el7.x86_64

将 CentOS 7 升级到 CentOS 8 服务器:

使用以下 rpm 命令删除所有已安装的内核。

[root@centos-7-server ~]# rpm -e `rpm -q kernel`

删除由上述命令提供的任何冲突软件包。
我们只有一个冲突包,例如:sysvinit-tools,我们正在使用 rpm 命令删除它。

[root@centos-7-server ~]# rpm -e --nodeps sysvinit-tools

在继续之前,请确保我们已删除所有冲突的软件包。
删除冲突包后,我们需要再次重复 rpm -e 'rpm -q kernel' 命令。

使用以下命令启动 Linux 操作系统升级。

[root@centos-7-server ~]# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync

安装新的 CentOS 8 内核内核。
如果我们想升级到最新的 Linux 内核, 可以阅读我们之前的文章。

[root@centos-7-server ~]# dnf install -y kernel-core

在服务器上安装 Minimal 和 Core 软件包组。

[root@centos-7-server ~]# dnf -y groupupdate "Core" "Minimal Install"

重新启动服务器以加载新的 Linux 内核。

[root@centos-7-server ~]# systemctl reboot

在 CentOS 7 上安装所需的软件包:

Linux 包管理器在升级过程中需要一些补充包。
因此,请使用 yum 命令安装这些软件包。

[root@centos-7-server ~]# yum install -y yum-utils rpmconf

升级到 CentOS 8 后验证软件版本:

重启后,检查安装的 Linux Kernel 的版本。

[root@centos-7-server ~]# uname -r
4.18.0-147.3.1.el8_1.x86_64

检查已安装的 Apache Web 服务器的版本。

[root@centos-7-server ~]# httpd -v
Server version: Apache/2.4.37 (centos)
Server built:   Dec 23 2019 20:45:34

检查已安装的 PHP 编程语言的版本。

[root@centos-7-server ~]# php -v
PHP 7.2.11 (cli) (built: Oct  9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

检查已安装的 MySQL 服务器的版本。

[root@centos-7-server ~]# mysql -V
mysql  Ver 15.1 Distrib 10.3.17-MariaDB, for Linux (x86_64) using readline 5.1

在 浏览器中打开 URL http://centos-7-server.onitroad.com。

在 CentOS 7 上安装 EPEL yum 软件库

我们需要一些在 EPEL(企业 Linux 的另外软件包)yum 存储库中可用的软件包。

因此,我们正在安装 epel-release 包以在我们的 Linux 服务器上启用 EPEL yum 存储库。

[root@centos-7-server ~]# yum install -y epel-release.noarch

为 EPEL yum 存储库构建缓存。

[root@centos-7-server ~]# yum makecache fast

CentOS 7 的 EPEL yum 存储库已安装。

如何将 CentOS 7 升级到 CentOS 8 Linux

在本文中,我们将学习如何将安装了LAMP 服务器的 CentOS 7 服务器升级到 CentOS 8 Linux,包括安装在该 Linux 服务器上的应用软件。

收集有关 CentOS 7 服务器的系统信息:

使用 ssh 客户端以 root 用户身份连接 centos-7-server.onitroad.com。

检查 Linux 内核的当前版本。

[root@centos-7-server ~]# uname -r
3.10.0-1062.7.1.el7.x86_64

检查 Apache Web 服务器的当前版本。

[root@centos-7-server ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Aug  8 2019 11:41:18

检查 PHP 编程语言的当前版本。

[root@centos-7-server ~]# php -v
PHP 5.4.16 (cli) (built: Nov  1 2019 16:04:20)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

检查 MySQL 服务器的当前版本。

[root@centos-7-server ~]# mysql -V
mysql  Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1

在网络浏览器中打开 URL http://centos-7-server.onitroad.com。

将 Yum 软件库从 CentOS 7 升级到 CentOS 8:

要升级我们的 yum 存储库,我们必须将 centos-release 软件包从 CentOS 7 升级到 CentOS 8.

[root@centos-7-server ~]# dnf upgrade -y http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-release-8.1-1.1911.0.8.el8.x86_64.rpm,centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm,centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm}

将 EPEL yum 存储库从 EL 7 升级到 EL 8.

[root@centos-7-server ~]# dnf upgrade -y epel-release

为所有 yum 存储库构建缓存。

[root@centos-7-server ~]# dnf makecache

我们所有的 yum 软件库都已从 CentOS 7 升级到 CentOS 8.

日期:2020-09-17 00:11:54 来源:oir作者:oir