将Centos 6系统升级到Centos 7

几年前,只有通过完整格式和所需版本的操作系统的新安装才能升级Linux版本。但是开发人员社区为启用OS升级付出了很多努力。整个阶段经过大量的试验和测试,直到最近才获得成功。

尽管有可用的选项,还是强烈建议您备份现有数据,使用CentOS 7执行全新安装,并从较早版本的CentOS复制以前的数据。这是因为在升级时记录了许多故障,并且在此过程中可能会丢失数据。如果您使用的是非官方存储库,安装在存储库外部的任何第三方软件包等,则可能由于多种原因而发生这种情况。

将CentOS 6.x升级到CentOS 7.x

步骤1.A
确保已将当前版本的CentOS 6.x更新为最新版本的CentOS(应为6.5或更高版本)。

Note: Move to Step 1.B if your current system is already up to date.

您可以使用以下命令执行更新

# yum update

这会将所有系统软件及其依赖项升级到最新版本。

步骤1.B
现在,一旦我们将系统更新到最新版本,就可以执行升级。首先,您将需要运行一个程序来扫描您的系统并确定您的升级状态。该程序称为“ 预升级助手 ”。

在命令提示符下,键入以下内容

sudo preupg

输出应类似于以下内容

sudo preupg
Preupg tool doesn't do the actual upgrade.
Please ensure you have backed up your system and/or data in the event of a failed upgrade
that would require a full re-install of the system from installation media.
Do you want to continue? y/n

y

Gathering logs used by preupgrade assistant:

All installed packages : 01/10 ...finished (time 00:00s)
All changed files : 02/10 ...finished (time 00:48s)
Changed config files : 03/10 ...finished (time 00:00s)
All users : 04/10 ...finished (time 00:00s)
...
042/100 ...done (samba shared directories selinux)
043/100 ...done (CUPS Browsing/BrowsePoll configuration)
044/100 ...done (CVS Package Split)
...
|samba shared directories selinux |notapplicable |
|CUPS Browsing/BrowsePoll configuration |notapplicable |

NOTE: The Preupgrade assistant does not perform the upgradation but only tells you if there will be any issues while performing an upgrade. It is recommended you perform this task to know for sure if the upgradation will be successful.

第2步
现在,我们进入下一步,即在运行最终升级过程之前获取CentOS 7密钥。您可以使用以下命令导入密钥

第三步
运行以下命令以执行升级。

sudo /usr/bin/redhat-upgrade-tool-cli --network 7 --instrepo=http://mirror.centos.org/centos/7/os/x86_64

运行上述命令后,升级过程将检索新的启动映像并下载必要的软件包,然后将要求重新启动。

系统可能会在此过程中执行几次重新引导,并应成功将当前CentOS升级到版本7.x。
您可以运行以下命令来检查系统的新版本

# cat /etc/centos-release

样本输出:

CentOS Linux版本7.4.1708