Debian 10 升级 Debian 11 教程

Debian 11(Bullseye)是 Debian Linux 系统的新版本,提供了广泛的更新软件包,并且提供五年的技术支持。本文介绍如何将现有的 Debian 10 服务器升级到 Debian 11,操作之前建议做好备份工作。此外,生产环境其实不建议直接这么升级,宁可选择重新部署。

一、更新现有服务器包

1、以具有 sudo 权限的普通用户身份通过 SSH 连接到服务器。

2、在从 Debian 10 切换之前更新您现有的服务器软件包、安全补丁和必要的升级是一个很好的做法,以确保您的应用程序与 Debian 11 兼容。

3、更新可用的软件包。

$ sudo apt update

4、升级所有现有的软件包。

$ sudo apt upgrade

5、删除任何不必要的依赖文件。

$ sudo apt autoremove

二、更改 Debian 源

Aptitude(Apt)从一个或多个存储库下载软件包以安装在您的服务器上(在 Debian 和 Ubuntu 中使用 APT 管理软件包)。 它会在 /etc/apt/sources.list 中找到要下载的正确存储库、可用软件包和版本。因此,您需要将 /etc/apt/sources.list 中的所有 Debian 10 代号替换为 Debian 11 代号。

1、通过运行以下命令确认 Debian 10 代号。Debian 10 的代号为 buster。

$ lsb_release -a

你的输出应该是:

No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster

2、将源列表中的所有 buster 条目更改为 Bullseye,这是 Debian 11 的代号。

3、将原始配置文件备份到您的主目录。

$ sudo cp /etc/apt/sources.list ~/sources.bak
$ sudo cp -r /etc/apt/sources.list.d/ ~/sources.list.d.bak

4、在您喜欢的编辑器中打开 /etc/apt/sources.list。

$ sudo nano /etc/apt/sources.list

5、当前条目应如下所示:

deb http://deb.debian.org/debian/ buster main
deb-src http://deb.debian.org/debian/ buster main

deb http://security.debian.org/debian-security buster/updates main
deb-src http://security.debian.org/debian-security buster/updates main

# buster-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ buster-updates main
deb-src http://deb.debian.org/debian/ buster-updates main

将这些行替换为:

deb http://deb.debian.org/debian bullseye main
deb-src http://deb.debian.org/debian bullseye main

deb http://security.debian.org/ bullseye-security main
deb-src http://security.debian.org/ bullseye-security main

deb http://deb.debian.org/debian bullseye-updates main
deb-src http://deb.debian.org/debian bullseye-updates main

6、保存并关闭文件。

7、再次更新软件包列表。如果您正确地进行了更改,则在更新过程中不会显示任何错误。

$ sudo apt update

8、执行系统升级。使用 --without-new-pkgs 标志来避免删除您打算保留在服务器上的软件包。

$ sudo apt upgrade --without-new-pkgs

系统将提示您重新启动特定服务或保留和删除特定配置选项。回答 Yes。

9、安装 apt-listchanges 包后,它将显示有关升级包的信息。键入 Q 退出。

10、选择一个控制台编码集,然后继续进行其他升级。

三、Debian 系统升级教程

现在,您可以使用以下命令安全地运行到 Debian 11 的完整升级:

$ sudo apt full-upgrade

这会将服务器从 Debian 10 完全升级到 Debian 11,解决可能的依赖关系更改,安装所有软件包的最新版本,并删除所有过时的软件包。在系统升级过程中,可能会显示其他提示以重新启动服务和更新现有配置选项。请务必选择适当的选项以避免对现有应用程序进行不必要的更改。

当显示寻呼机指示器 : 时,键入 Q 继续。

当提示修改 /etc/sysctl.conf 时键入 Y。

Configuration file '/etc/sysctl.conf'
 ==> Modified (by you or by a script) since installation.
 ==> 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
      Z     : start a shell to examine the situation
 The default action is to keep your current version.

四、重启服务器

1、系统升级完成后,重新启动服务器以使更改生效。

$ sudo reboot now

您当前的 SSH 连接将被删除。

2、等待一分钟,让服务器重新启动。

3、通过 SSH 登录。

4、检查当前的操作系统版本并验证它是否显示 Debian 11,bullseye。

$ lsb_release -a

输出:

No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

五、验证应用程序和服务

在升级过程中,一些软件包可能已经升级到较新的版本,但它们仍将使用相同的配置文件和端口。逐一验证您现有的应用程序,并根据您的服务器设置检查错误日志。例如,检查 Apache2 是否已安装并运行:

$ sudo service apache2 status

要确认 MySQL 是否存在:

$ sudo service mysql status

检查当前 PHP 版本:

$ php -v

六、服务器安全设置

在从 Debian 10 升级到 Debian 11 的过程中,一些应用程序可能需要新版本。根据您的安装类型,一些应用程序可能已在此过程中自动更新,或者您可能必须手动更新最新版本。 要保护服务器,请删除所有过时的软件包。

$ sudo apt --purge autoremove

确认简单防火墙 (ufw) 是否正在运行并设置一些规则以加强与服务器的连接。

$ sudo ufw status

要允许 HTTP 之类的服务,请运行:

$ sudo ufw allow http

现在已经将服务器从 Debian 10 “Buster”升级到 Debian 11 “Bullseye”,并在服务器上保留了现有应用程序。

未经允许不得转载:主机格调 » Debian 10 升级 Debian 11 教程

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏