「CentOS」- 安装与升级

  CREATED BY JENKINSBOT

版本命名

CentOS Wiki/FAQ/General/How does CentOS versioning work?
Wikipedia/CentOS

Since minor versions of CentOS are point in time releases of a major branch, starting with CentOS-7, we are now using a date code in our minor versions. So you will see CentOS-7 (1406) or CentOS-7 (1503) as a version. This way anyone can know, from the release, when it happened. In the above examples, the minor versions 1406 means June 2014 and 1503 means March 2015. In older major branches of CentOS, such as CentOS-6, we numbered things differently.

7.0-1406
7.1-1503
7.2-1511
7.3-1611
7.4-1708
7.5-1804
7.6-1810
7.7-1908
7.8-2003
7.9-2009

相关链接

Instructions for installing CentOS 7.6.1810 on various architectures

升级 CentOS 6.5 到 CentOS 7 版本

Upgrade Centos 6 to Centos 7
Index of /centos/6/upg/old/x86_64/Packages
Upgrading CentOS 6 to 7
Pre Upgrade Assistant fails to generate a results.html
Upgrade from CentOS 6 to CentOS 7
Upgrading CentOS 6.5 to CentOS 7.2
Upgrading CentOS 6 to CentOS 7

以前升级系统的时候,只能通过重新安装。但是经过社区不断的努力,现在可以通过命令行直接升级当前系统。

注意事项

目前CentOS尚未发布任何有关升级CentOS 6的官方文件,因此不建议在生产环境中进行此升级。如果你想尝试开发,可以按照如下简单的步骤操作。

这是从别的博文中收到的警告:不要使用此方法升级「CentOS 6.7」或更高版本的系统。因为在「CentOS 6.7」中的多个系统关键软件包的版本号,比它们在「CentOS 7」中的版本号更高,因此这些软件包无法正确升级。这会导致系统损坏,并且几个系统工具无法正常工作。你将无法登录或使用网络。此外「CentOS 6.6」现在升级也会失败,升级时出现错误“Downloading failed: invalid data in .treeinfo: No section: ‘checksums’”,只能在「CentOS 6.5」上完成。

#1 更新系统

将系统中的包更新到最新的版本:

#!/bin/sh

yum update -y

#2 升级助手

升级助手不用于升级,它是升级检查工具。用于检查在升级过程中潜在的问题。

安装并执行升级助手:

#!/bin/sh

# 配置源
cat <<UA >> /etc/yum.repos.d/upgrade.repo
[upgrade]
name=upgrade
baseurl=https://buildlogs.centos.org/centos/6/upg/old/x86_64/
enabled=1
gpgcheck=0
UA

# 对openscap进行降级
# 因为一个错误:https://centos.org/forums/viewtopic.php?t=59763
yum erase openscap
yum -y install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm

# 安装升级助手
yum -y install redhat-upgrade-tool preupgrade-assistant-*

# 执行检查
preupg --text

从升级助手中可以找到所有将受此升级影响的包和应用程序。如果你觉得没有关系,那么可以继续下一步。

#3 执行升级

执行升级:

#!/bin/sh

# 如果链接无效,则访问http://centos.excellmedia.net/找到对应的文件,修改链接即可
# rpm --import http://centos.excellmedia.net/7.6.1810/os/x86_64/RPM-GPG-KEY-CentOS-7
# redhat-upgrade-tool --network 7.6 --force --instrepo http://centos.excellmedia.net/7.6.1810/os/x86_64/
rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
centos-upgrade-tool-cli --network 7 --instrepo=http://mirror.centos.org/centos/7/os/x86_64

# 上述命令执行结束后,需要在重启后进行安装
reboot

#4 验证版本

最后一步是验证系统的版本:

#!/bin/sh

cat /etc/redhat-release

常见错误汇总

Downloading failed: invalid data in .treeinfo: No section: ‘checksums’
参见本文开始时的注意事项。

YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
YumRepo Error: All mirror URLs are not using ftp, http[s] or file

注释掉中的mirrorlist选项,并启用baseurl选项。