linux之Centos6升级至centos7

一、需求说明

centos官方于2020年12月2号停止了所有centos6更新维护,为了继续享受更新服务,redhat提供了一个redhat-upgrade-tool的升级工具,支持将centos6升级到centos7。centos8停止维护更新时间2021年12月31号,centos7停止更新维护时间为2024年6月30号。centos停止更新后取而代之的是CentOS Stream。
示例环境说明:

  • 升级前版本:centos6.5
  • 升级后版本:centos7.0

二、升级步骤

0、查看操作系统版本

[root@localhost ~]# cat /etc/centos-release
CentOS release 6.5 (Final)

1、更换YUM源

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://files.tttidc.com/centos6/Centos-6.repo

2、安装升级软件工具

官方下载地址,一般网络从官方下载速度实在是慢得无法忍受。
下载地址一:官网下载地址
下载地址二:>CSDN下载地址
下载rpm包后上传到服务器解压后安装
[root@localhost opt]# yum localinstall preupgrade-assistant-* -y
[root@localhost opt]# yum localinstall redhat-upgrade-tool* -y

3、检测系统可否升级

[root@localhost opt]# preupg -l
CentOS6_7

4、运行模拟升级工具

[root@localhost opt]# preupg -s CentOS6_7
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 #此处输入y
Gathering logs used by preupgrade assistant:
All installed packages : 01/11 …finished (time 00:00s)
All changed files : 02/11 …finished (time 02:44s)
Changed config files : 03/11 …finished (time 00:00s)
All users : 04/11 …finished (time 00:00s)
All groups : 05/11 …finished (time 00:00s)
Service statuses : 06/11 …finished (time 00:00s)
All installed files : 07/11 …finished (time 00:02s)

Tarball with results is stored here /root/preupgrade-results/preupg_results-210324171443.tar.gz .
The latest assessment is stored in directory /root/preupgrade .
Summary information:
We found some critical issues. In-place upgrade is not advised.
Read the file /root/preupgrade/result.html for more details.
Upload results to UI by command:
e.g. preupg -u http://127.0.0.1:8099/submit/ -r /root/preupgrade-results/preupg_results-*.tar.gz .

5、根据模拟升级的检测结果进行确认和评估

[root@localhost ~]# preupg --riskcheck --verbose

INPLACERISK: MEDIUM: We detected some packages installed on the system were removed (obsoleted) between CentOS 6 and CentOS 7. This may break the functionality of the packages depending on them.
INPLACERISK: MEDIUM: We detected some packages installed on the system were removed between CentOS 6 and CentOS 7. This may break the functionality of the packages depending on them.
INPLACERISK: MEDIUM: Package ql2200-firmware not provided by its replacement linux-firmware. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package libudev not provided by its replacement systemd-libs. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package coreutils-libs not provided by its replacement coreutils. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package ql2500-firmware not provided by its replacement linux-firmware. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package ql2100-firmware not provided by its replacement linux-firmware. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package rt61pci-firmware not provided by its replacement linux-firmware. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package ql23xx-firmware not provided by its replacement linux-firmware. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package bfa-firmware not provided by its replacement linux-firmware. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package ql2400-firmware not provided by its replacement linux-firmware. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package rt73usb-firmware not provided by its replacement linux-firmware. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: Package sane-backends-libs-gphoto2 not provided by its replacement sane-backends-drivers-cameras. In-place upgrade might not work properly, will be finished by postupgrade script!
INPLACERISK: MEDIUM: having one of [openscap tzdata redhat-menus kpartx mesa-libGLU] package installed breaks upgrade
INPLACERISK: MEDIUM: We detected some soname bumps in the libraries installed on the system. This may break the functionality of some of your 3rd party applications. They may need rebuild. Please check their requirements.
INPLACERISK: MEDIUM: We detected some .so libraries installed on the system were removed between CentOS 6 and CentOS 7. This may break the functionality of some of your 3rd party applications.
INPLACERISK: SLIGHT: We detected some files where modifications are not tracked in the rpms. You may need to check their functionality after successful upgrade.
INPLACERISK: SLIGHT: We detected some files untracked by rpms. Some of these may need manual check/migration after redhat-upgrade-tool and/or can cause conflicts or troubles during the installation. Try to reduce unnecessary untracked files before running redhat-upgrade-tool.
INPLACERISK: SLIGHT: We detected some packages installed on the system changed their name between CentOS 6 and CentOS 7. Altho h they should be compatible, monitoring after the update is recommended.
INPLACERISK: SLIGHT: export shell commands will be deleted from /etc/sysconfig/sshd
INPLACERISK: SLIGHT: Some binaries untracked by RPM were discovered on the system and may need rebuild after upgrade.
INPLACERISK: SLIGHT: Some scripts untracked by RPM were discovered on the system and may not work properly after upgrade.
INPLACERISK: SLIGHT: /usr/lib64/python2.6/site-packages/gtk-2.0 is owned by an RPM package that was not signed by CentOS.
INPLACERISK: SLIGHT: /usr/lib64/python2.6/site-packages/report is not owned by any RPM package.
INPLACERISK: SLIGHT: /usr/lib64/python2.6/site-packages/reportclient is not owned by any RPM package.

检测评估结果提示风险项,我这是初始化的centos6.5操作系统,风险提示内容都有不少。存在EXTREME错误则无法进行下一步升级操作。

7、安装升级用的centos7 rpm key

[root@localhost ~]# rpm --import http://vault.centos.org/centos/7.0.1406/os/x86_64/RPM-GPG-KEY-CentOS-7
[root@localhost ~]# centos-upgrade-tool-cli --network 7 --instrepo=http://vault.centos.org/centos/7.0.1406/os/x86_64/
setting up repos…
base | 3.7 kB 00:00
base/primary_db | 4.7 MB 00:01

8、运行升级工具

只支持6.5及以上系统升级到不高于7.2系统;

  • 1)、直接从网络源进行更新

[root@localhost ~]# centos-upgrade-tool-cli --network 7 --instrepo=http://vault.centos.org/centos/7.0.1406/os/x86_64/
setting up repos…
upgradedevice | 3.6 kB 00:00 …
upgradedevice/primary_db | 2.7 MB 00:00 …
Preupgrade assistant risk check found risks for this upgrade.
You can run preupg --riskcheck --verbose to view these risks.
Addressing high risk issues is required before the in-place upgrade
and ignoring these risks may result in a broken upgrade and unsupported upgrade.
Please backup your data.

Continue with the upgrade [Y/N]? y

rpm install 100% [============================================================================================]
setting up system for upgrade
Finished. Reboot to start upgrade.

  • 2)、从本地源进行更新

    • 下载centos7.0.1406镜像iso文件
  • [root@localhost home]# wget https://vault.centos.org/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-DVD.iso

    • 挂载镜像
  • [root@localhost home]# mout -o -loop -t iso9660 /home/CentOS-7.0-1406-x86_64-DVD.iso /mnt/cdrom

    • 执行更新
  • [root@localhost home]# centos-upgrade-tool-cli --device=/dev/cdrom

9、重启操作系统

[root@localhost home]# reboot

10、查验系统版本

[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 7.0.1406 (Core)

三、FAQ

1、安装redhat-upgrade-tool时报错File contains no section headers.

  • 报错信息:
    在这里插入图片描述
  • 问题原因:
    repo配置文件错误,缺少配置头信息
  • 解决方案:
    -将缺少的yum头信息添加上 [centos6-upgrade]

[root@localhost yum.repos.d]# cat upgradtool.repo.bak
[centos6-upgrade]
name=CentOS-$releasever - Upgrade Tool
baseurl=http://dev.centos.org/centos/6/upg/x86_64/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

2、安装redhat-upgrade-tool时报错Couldn’t resolve host ‘dev.centos.org’

  • 报错信息:
    在这里插入图片描述

  • 问题原因:
    centos官网已经停止centos6相关服务,网站dev.centos.org已经停止服务。

  • 解决方案:
    按照博文步骤,手动安装redhat-upgrade-tool等rpm包。

3、模拟升级时报错

  • 报错信息:
    在这里插入图片描述

  • 问题原因:
    openscap版本太高,需要降级

  • 解决方案:
    卸载当前安装的openscap版本,下载并安装openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm

[root@localhost opt]# rpm -qa |grep openscap
openscap-1.2.13-2.el6.x86_64
[root@localhost opt]# rpm -e --nodeps openscap-1.2.13-2.el6.x86_64
[root@localhost opt]# yum localinstall openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm -y

4、模拟升级的检测结果存在关于X11的EXTREME问题

  • 报错信息:
    在这里插入图片描述

  • 问题原因:
    centos7对X11桌面环境进行了重新设计

  • 解决方案:
    因centos6作为服务器,当前安装软件没有桌面要求,选择卸载X11桌面环境。
    #yum groupremove -y “Desktop” “X Window System”

5、模拟升级的检测结果存在关于pcnet32的EXTREME问题

  • 报错信息:
    INPLACERISK: EXTREME: The kernel driver ‘pcnet32’ required to service hardware present in your system is not available in CentOS 7. This suggests that your system contains hardware that is not supported in CentOS 7 release.
  • 问题原因:
    vmware 提供的默认网卡类型是pcnet32,el7默认没有提供pcnet32的网卡驱动。
  • 解决方案:
    在vmware指定的虚拟机存储位置找到.vmx的文件,
    ethernet0.virtualDev = “pcnet32” 或是别的。将其修改为:
    ethernet0.virtualDev = “e1000”’ (如果没有添加)

四、写着最后

centos6升级centos7跨越大版本,可能的报错实在是太多,成功的几率也不高,花费的时间成本远远大于新装机centos7的成本。实际中建议新搭建centos7环境测试部署的应用是否兼容,测试通过直接通过新装系统重新部署应用的方式升级。本人仅供学习参考,无法保证升级成功。

本文来自网络,不代表本站立场,转载请注明出处:万道一,Wonder One » linux之Centos6升级至centos7
莫要搞事情哦
你喜欢的人刚好也未喜欢你
张学友刘德华邓紫琪已关注
赞(0) 打赏

赏点小费吧客倌

微信扫一扫打赏