介绍
<$>[警告] 警告: 与操作系统的主要版本之间几乎任何升级一样,此过程具有固有故障、数据丢失或软件配置故障的风险。
为了避免这些问题,如果可能的话,我们建议迁移到新的Ubuntu 16.04服务器,而不是在现场升级,您可能需要在升级时查看软件配置的差异,但核心系统可能具有更大的稳定性。
Ubuntu 操作系统的下一个长期支持版本,版本 16.04 (Xenial Xerus),将于 2016 年 4 月 21 日发布。
虽然在写作时尚未发布,但已经可以将 15.10 系统升级到 16.04 开发版本,这可能有助于在官方发布日期之前测试升级过程和 16.04 本身的功能。
本指南将解释系统的过程,包括(但不限于)运行Ubuntu 15.10的DigitalOcean Droplets。
前提条件
本指南假定您有一个运行 Ubuntu 15.10 的系统,配置为非根用户,具有sudo
权限用于管理任务。
潜在的陷阱
虽然许多系统可以在现场进行升级,但通过从头开始安装发行版,通过仔细测试配置服务,并作为一个单独的步骤迁移应用程序或用户数据,迁移到一个主要的新版本往往更安全和更可预测。
在Ubuntu 16.04中,从未先测试所有部署的软件和服务,否则不会在舞台环境中进行升级。请记住,图书馆、语言和系统服务可能发生了重大变化。
在升级之前,请考虑阅读 Xenial Xerus Release Notes。
步骤1 - 备份您的系统
在尝试在任何系统上进行重大升级之前,您应该确保在升级失败时不会丢失数据. 实现这一点的最佳方法是对整个文件系统进行备份。 如果没有,请确保您有用户主目录的副本,任何自定义配置文件,以及服务(如关系数据库)存储的数据。
在DigitalOcean Droplet中,最简单的方法是下载系统并拍摄一张快照(下载确保文件系统更加一致)。 请参阅 如何使用DigitalOcean快照自动备份您的快照 有关快照过程的详细信息。
对于大多数 Ubuntu 系统上可用的备份方法,请参阅 如何为 VPS 选择有效的备份策略。
步骤 2 – 升级当前安装的软件包
在启动版本升级之前,最安全的是安装最新版本的所有包 对于当前版本. 开始更新包列表:
1sudo apt-get update
接下来,将安装的软件包升级到其最新的可用版本:
1sudo apt-get upgrade
您将看到升级列表,并被要求继续。 回答 y 是的,并按 Enter。
此过程可能需要一段时间。一旦完成,请使用dist-upgrade
命令,该命令将执行升级,涉及更改依赖性,根据需要添加或删除新包。
1sudo apt-get dist-upgrade
再次,当被要求继续时,回答 y,然后等待升级完成。
现在你已经安装了Ubuntu 15.10,你可以使用Do-release-upgrade
升级到16.04版本。
步骤 3 – 使用 Ubuntu 的 do-release-upgrade 工具进行升级
首先,请确保安装了update-manager-core
包:
1sudo apt-get install update-manager-core
传统上,Debian 版本可以通过更改 Apt 的 /etc/apt/sources.list 来升级,该列表指定了包存库,并使用
apt-get dist-upgrade' 来执行升级本身。Ubuntu 仍然是 Debian 衍生发行版,所以这个过程可能仍然可以工作。
開始執行「執行發行升級」,沒有選項:
1sudo do-release-upgrade
如果 Ubuntu 16.04 尚未发布,您应该看到以下内容:
1[label Sample Output]
2Checking for a new Ubuntu release
3No new release found
要在正式发布之前升级到 16.04,请指定 -d
选项以使用 development 版本:
1sudo do-release-upgrade -d
如果你通过SSH连接到你的系统,就像DigitalOcean Droplet一样,你会被问到是否想继续。
在Droplet上,通过SSH升级是安全的,虽然升级发布
没有通知我们,但您可以使用DigitalOcean控制面板的控制台连接到您的Droplet而不运行SSH。
对于由其他提供商托管的虚拟机或管理服务器,您应该记住,失去 SSH 连接是一种风险,特别是如果您没有其他方式来远程连接到系统主机。
在提示中,键入 y 并按 Enter 继续:
1Reading cache
2
3Checking package manager
4
5Continue running under SSH?
6
7This session appears to be running under ssh. It is not recommended
8to perform a upgrade over ssh currently because in case of failure it
9is harder to recover.
10
11If you continue, an additional ssh daemon will be started at port
12'1022'.
13Do you want to continue?
14
15Continue [yN] y
接下来,您将被告知Do-release-upgrade
正在在端口 1022 上启动一个新的sshd
实例:
1Starting additional sshd
2
3To make recovery in case of failure easier, an additional sshd will
4be started on port '1022'. If anything goes wrong with the running
5ssh you can still connect to the additional one.
6If you run a firewall, you may need to temporarily open this port. As
7this is potentially dangerous it's not done automatically. You can
8open the port with e.g.:
9'iptables -I INPUT -p tcp --dport 1022 -j ACCEPT'
10
11To continue please press [ENTER]
在DigitalOcean系统上,忽略此警告并继续升级是安全的,因为实际上可以使用16.04的本地镜子。
1Updating repository information
2
3No valid mirror found
4
5While scanning your repository information no mirror entry for the
6upgrade was found. This can happen if you run an internal mirror or
7if the mirror information is out of date.
8
9Do you want to rewrite your 'sources.list' file anyway? If you choose
10'Yes' here it will update all 'trusty' to 'xenial' entries.
11If you select 'No' the upgrade will cancel.
12
13Continue [yN] y
一旦下载了新包列表并计算了更改,您将被问及是否要开始升级。
1Do you want to start the upgrade?
2
36 installed packages are no longer supported by Canonical. You can
4still get support from the community.
5
69 packages are going to be removed. 104 new packages are going to be
7installed. 399 packages are going to be upgraded.
8
9You have to download a total of 232 M. This download will take about
1046 seconds with your connection.
11
12Installing the upgrade can take several hours. Once the download has
13finished, the process cannot be canceled.
14
15 Continue [yN] Details [d]y
新的包将被检索,然后解包和安装,即使您的系统在快速连接,这将需要一段时间。
在安装过程中,您可能会收到交互式对话框以回答各种问题,例如,您可能会被问及在需要时是否要自动重新启动服务:
在这种情况下,回答是
是安全的。在其他情况下,您可能会被问及是否想用正在安装的软件包的默认版本替换您所修改的配置文件。
一旦新包已完成安装,您将被问及是否准备好删除过时的包。在没有自定义配置的库存系统上,应该安全地在这里输入 y。在您大大修改的系统上,您可能希望输入 d并检查要删除的包的列表,如果它包含任何您需要稍后重新安装的内容。
1Remove obsolete packages?
2
353 packages are going to be removed.
4
5 Continue [yN] Details [d]y
最后,假设一切顺利,您将被告知升级完成,需要重新启动。
1System upgrade is complete.
2
3Restart required
4
5To finish the upgrade, a restart is required.
6If you select 'y' the system will be restarted.
7
8Continue [yN] y
在 SSH 会话中,您可能会看到以下内容:
1=== Command detached from window (Thu Apr 7 13:13:33 2016) ===
2=== Command terminated normally (Thu Apr 7 13:13:43 2016) ===
您可能需要按下一个键来退出本地提示,因为您的SSH会话将在服务器端结束. 等待一会儿,您的系统重新启动,并重新连接。
1Welcome to Ubuntu Xenial Xerus (development branch) (GNU/Linux 4.4.0-17-generic x86_64)
结论
您现在应该有一个运行Ubuntu 16.04的安装。从这里开始,您可能需要调查所部署的服务和应用程序所需的配置更改。