- Ubuntu 18.04是一个长期支持(LTS)版本,LTS 版本每两年发布一次,而 Ubuntu 18.04 是自 2016 年以来的第一个长期支持版本。Ubuntun 长期支持版本可以获得 Canonical 官方长达五年的技术支持,这意味着在 2023 年之前所有用户都可以放心使用 Ubuntu 18.04 LTS。。本教程将展示如何将您的CVM从Ubuntu 16.04(Xenial Xerus)或Ubuntu 17.10(Artful Aardvark)升级到Ubuntu 18.04(Bionic Beaver) )。
准备
本教程需要一台已经设置好可以使用sudo
命令的非root账号的CentOS服务器,并且已开启防火墙。没有服务器的同学可以在购买,不过我个人更推荐您使用免费的腾讯云开发者实验室进行试验,学会安装后在购买服务器。所有步骤需要root权限。请务必以root身份或使用sudo
运行以下步骤。
本教程的以下步骤将:
- 安装Ubuntu 16.04的更新。
- 备份您的数据。
- 确保您使用的内核版本是最新版本。
- 停止非关键服务。
- 启动LISH会话以确保安装不会中断。
安装可用更新
更新包列表并安装所有更新:
apt update && apt upgrade
备份CVM
在执行重大升级之前请备份您的CVM。如果在升级过程中出现任何问题,您可以从备份恢复。我们建议您在升级到Ubuntu 18.04 LTS之前手动快照。如果您使用其他备份服务或应用程序,我们建议您在继续之前进行手动备份。
停止服务
我们建议您在升级到Ubuntu 18.04 LTS之前尽可能多的停止无关服务。这包括Web服务器守护程序(Apache和NGINX),数据库服务器(PostgreSQL和MySQL)以及任何其他非关键服务。
- 获取当前在您的系统上运行的服务列表:
systemctl | grep running
-
要停止服务,请输入以下命令,比如我要停止apache运行,则用下面的命令,替换为要停止的服务
apache2
的名称:
systemctl stop apache2
您现在可以在您的CVM上安装Ubuntu 18.04 LTS了。
从Ubuntu 16.04 LTS升级到Ubuntu 18.04 LTS
接下来,请在会话中执行以下步骤:
安装update-manager-core
包:
apt install update-manager-core
打开/etc/update-manager/release-upgrades
并验证该Prompt
值是lts
在Ubuntu 16.04或normal
Ubuntu 17.10上设置的:
/etc/update-manager/release-upgrades
# Default behavior for the release upgrader. [DEFAULT] # Default prompting behavior, valid options: # # never - Never check for a new release. # normal - Check to see if a new release is available. If more than one new # release is found, the release upgrader will attempt to upgrade to # the release that immediately succeeds the currently-running # release. # lts - Check to see if a new LTS release is available. The upgrader # will attempt to upgrade to the first LTS release available after # the currently-running one. Note that this option should not be # used if the currently-running release is not itself an LTS # release, since in that case the upgrader won't be able to # determine if a newer release is available. Prompt=lts
您现在已准备好开始升级到Ubuntu 18.04 LTS。Ubuntu鼓励将LTS发行版升级为带.1
的版本(例如18.04.1
),使用-d
选项强制它识别新版本:
do-release-upgrade -d
按照屏幕上的说明完成安装过程。
由于CVM为Ubuntu提供了内部包镜像,因此您可能会看到以下的某些消息:
- 找不到有效的镜像
While scanning your repository information no mirror entry for the upgrade was found. This can happen if you run an internal mirror or if the mirror information is out of date. Do you want to rewrite your 'sources.list' file anyway? If you choose 'Yes' here it will update all 'trusty' to 'xenial' entries. If you select 'No' the upgrade will cancel. Continue [yN]
键入y
并回车继续。
- 安装包不再支持
3 installed packages are no longer supported by Canonical. You can still get support from the community. 2 packages are going to be removed. 91 new packages are going to be installed. 346 packages are going to be upgraded. You have to download a total of 239 M. This download will take about 30 minutes with a 1Mbit DSL connection and about 9 hours with a 56k modem. Fetching and installing the upgrade can take several hours. Once the download has finished, the process cannot be canceled. Continue [yN] Details [d]
按d
阅读详细信息(然后按q
退出详细信息),或按y
继续。
-
配置openssh-server:按enter键选择
keep the local version currently installed
。
-
删除过时的安装包?:输入
y
升级将重新启动。输入y
继续:
System upgrade is complete. Restart required To finish the upgrade, a restart is required. If you select 'y' the system will be restarted. Continue [yN]
系统重新启动后,验证它是否正在运行Ubuntu 18.04:
lsb_release -a
您应该看到类似于以下内容的输出:
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04 LTS Release: 18.04 Codename: bionic
您的CVM现在将运行Ubuntu 18.04 LTS。
从旧的Ubuntu版本升级
如果您的Linode运行的是早于16.04 LTS的Ubuntu版本,请首先升级到Ubuntu 16.04 LTS。然后,您可以将您的CVM升级到Ubuntu 18.04 LTS。你可以参考如何将Ubuntu升级到18.04最新版我们的另一篇教程文章。