本文依照redhat官方文档制作,总共分为两步,先将centos7转换为rhel7,然后再将rhel7升级为rhel8

参考文档:
cenots7转换为rhel7
rhel7升级为rhel8

centos7升级为rhel7

升级到centos7最新版

1
yum update -y && reboot

安装convert2rhel

1
2
3
4
5
6
7
curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release https://www.redhat.com/security/data/fd431d51.txt


curl -o /etc/yum.repos.d/convert2rhel.repo https://ftp.redhat.com/redhat/convert2rhel/7/convert2rhel.repo


yum install -y convert2rhel

开始转换

1
2
convert2rhel --username <替换为你的用户名> --password <替换为你的密码>
不加--pool 会提示手动选择,为了安全也可以不加参数直接运行convert2rhel

rhel7 升级 rhel8

启用这两个仓库

1
2
subscription-manager repos --enable rhel-7-server-rpms && \
subscription-manager repos --enable rhel-7-server-extras-rpms

取消版本锁定?

1
2
subscription-manager release --unset
yum versionlock clear

确保locale是en_US

1
2
cat /etc/locale.conf
LANG="en_US.UTF-8"

安装leapp

1
2
yum update && reboot
yum install leapp leapp-repository

Leapp实用程序所需的数据

数据来自于https://access.redhat.com/articles/3664871

1
tar -xzf leapp-data14.tar.gz -C /etc/leapp/files && rm leapp-data14.tar.gz

准备升级,检查问题

1
leapp preupgrade

创建应答文件,做出响应

1
leapp answer --section remove_pam_pkcs11_module_check.confirm=True

或者修改/var/log/leapp/answerfile

开始升级,在终端来升级,不要远程连接

1
leapp upgrade

升级完成清理仓库

1
2
yum remove epel-release puppet5-release ...
/etc/yum.repos.d/

打开selinux

1
vim /etc/selinux/config

升级完检查

1
2
3
4
subscription-manager list --installed
uname -r
subscription-manager release
cat /etc/redhat-release