CentOS 7 升级 Rocky Linux 9
CentOS 7 生命周期在2024年6月30日结束,官方不再为 CentOS7 提供任何的技术支持和软件更新服务。
常见 RHEL 系列的操作系统有:
- Red Hat Enterprise Linux(RHEL)
- CentOS
- CentOS Stream
- Rocky Linux
- AlmaLinux
几者的关系:
- rpm 包通用。
- 命令通用。
- CentOS 是 CentOS 社区重新编译 Red Hat 源代码生成的免费版本。
- CentOS Stream 是 CentOS 滚动升级的版本,由 CentOS 官方提供。
- Rocky Linux 和 AlmaLinux 都是基于 RHEL 源代码和二进制文件的克隆版本。
AlmaLinux 官网有一张对比表:
Benchmarking against RHEL | AlmaLinux | Oracle Linux | Rocky Linux | CentOS Stream | CentOS Linux |
---|---|---|---|---|---|
Production Version | Since March 2021 | Since 2006 | Since June 2021 | Since 2019 | Since 2004 |
RHEL compatibility | Binary Compatible | ABI Compatible? | Binary compatible | Compatible within the limits of the ACG | Binary Compatible |
Regular updates delay | About 1 business day | About 1 business day | About 1 business day | Upstream of RHEL | About 1 business day |
Last minor version release delay | 1 day | 7 days | 5 days | N/A | N/A |
Errata | Yes | Yes | Yes | No | No |
Lifecycle | 10 Years | 10 Years | 10 Years | 5-6 Years | EOL on 2021-12-31 |
Commercial support | 3rd party | Oracle, 3rd parties | 3rd Party | 3rd party | 3rd party |
Livepatching service | KernelCare | Oracle Ksplice, KernelCare Available | KernelCare Available | Not available | KernelCare, Kpatch |
FIPS compliance | Yes | Yes | Planned | Not available | Not available |
ARM support | Yes | Yes | Yes | Yes | Yes |
IBM PowerPC support | Yes | No | Yes (versions ≥ 9) | Yes | Yes |
IBM Z (s390x) support | Yes | No | Yes (versions ≥ 9) | No | No |
SecureBoot | Yes | Yes | Yes | Yes | Yes |
Owned By: | AlmaLinux OS Foundation | Oracle Inc | Rocky Enterprise Software Foundation | Red Hat Inc | Red Hat Inc |
Owned by org type: | Non-Profit 501(c)6 | For Profit C-Corp | For Profit, Public Benefit Corp | For Profit C-Corp | For Profit C-Corp |
AlmaLinux和Rocky Linux都是作为CentOS的替代品推出的开源企业级Linux发行版,旨在提供与Red Hat Enterprise Linux (RHEL) 高度兼容的稳定环境,特别是在CentOS宣布改变其发布策略之后,这两个项目成为了焦点。以下是它们之间的一些关键区别和特点:
社区与支持背景:
- AlmaLinux: 虽然微软通过其“Azure投资计划”对 AlmaLinux 的开发有所贡献,但项目本身是由非营利组织 AlmaLinux Foundation 管理的,旨在保持独立性和社区驱动。它强调快速响应红帽企业 Linux(RHEL)的更新,并迅速提供相应的稳定版本。
- Rocky Linux: 由 CentOS 的联合创始人 Gregory Kurtzer 发起,Rocky Linux 得到了谷歌等公司的支持。项目注重稳定性、安全性和长期支持,旨在成为 CentOS 的直接继承者,提供一个可靠的企业级平台。
维护和更新策略:
- 两者都承诺提供与 RHEL 高度兼容的体验,包括软件包、系统管理工具和整体生态系统。
- 它们都遵循长期支持模型,确保用户可以获得定期的安全更新和维护。
生态系统与兼容性:
- 由于两者都是基于 RHEL 源码重新编译,因此在软件包兼容性方面几乎一致,都能无缝替代 CentOS 使用。
- 它们都有活跃的社区支持,提供文档、论坛和用户交流平台。
选择考量:
- 对于选择哪个发行版,最终决策可能取决于个人或组织的偏好,包括社区参与度、长期支持的信心、特定功能或集成需求,以及对项目背后支持者的信任度。
最新动态:
- 截至最近的资料(2024年5月9日),AlmaLinux 最新版本是 9.4,Rocky Linux 最新版本是9.3。可见 AlmaLinux 的更新是更紧跟 RHEL 的步伐的。
AlmaLinux 和 Rocky Linux 都是可靠的选择,适合那些寻找 CentOS 替代方案的用户。在选择时,考虑项目的社区活力、长期支持计划、以及你对它们各自背后支持者的信心可能是重要的因素。
升级路径
不支持从7直接升级到9,需要先升级到8,再升级到9
CentOS 7 --> Rocky Linux 8.9 --> Rocky Linux 9.3
注意事项
- Rocky Linux 9 不再支持 network.service 管理网络接口,需要使用 NetworkManager,并且保证 NetworkManager 服务开机自启动,否则升级后重启连不上服务器
- 原地升级有风险,请备份好数据,做好快照
- 重装系统可能是更好的选择,如果非得要原地升级,请在测试环境做好充足的验证
7 升 8
安装 epel-release
yum install epel-release
更新系统
yum update -y
安装依赖
yum -y install rpmconf dnf
# 执行rpmconf ,如果出现一些提示,请输入Y和回车继续
rpmconf -a
# 移除yum和yum-metadata-parser
dnf -y remove yum yum-metadata-parser
安装 Rocky Linux 8.9 软件源
# 删除CentOS7的源
rpm -e --nodeps `rpm -qa|grep centos-`
# 安装RockyLinux8.9的源
rpm -ivh --nodeps --force https://mirrors.aliyun.com/rockylinux/8/BaseOS/x86_64/os/Packages/r/rocky-release-8.10-1.9.el8.noarch.rpm
rpm -ivh --nodeps --force https://mirrors.aliyun.com/rockylinux/8/BaseOS/x86_64/os/Packages/r/rocky-repos-8.10-1.9.el8.noarch.rpm
rpm -ivh --nodeps --force https://mirrors.aliyun.com/rockylinux/8/BaseOS/x86_64/os/Packages/r/rocky-gpg-keys-8.10-1.9.el8.noarch.rpm
# 升级epel源
dnf -y upgrade https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
dnf clean all
删除 kernel
rpm -e --nodeps `rpm -qa|grep kernel`
执行升级
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
报错
错误:事务检查与依赖解决错误:
(NetworkManager >= 1.20 or dhclient) 被 dracut-network-049-228.git20230802.el8.x86_64 需要
rpmlib(RichDependencies) <= 4.12.0-1 被 dracut-network-049-228.git20230802.el8.x86_64 需要
解决
dnf remove dracut-network
再次尝试升级,报错
错误:事务检查错误:
file /usr/lib64/.libcrypto.so.1.1.1k.hmac from install of openssl-libs-1:1.1.1k-12.el8_9.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-7.el7.x86_64
file /usr/lib64/.libssl.so.1.1.1k.hmac from install of openssl-libs-1:1.1.1k-12.el8_9.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-7.el7.x86_64
file /usr/lib64/engines-1.1/afalg.so from install of openssl-libs-1:1.1.1k-12.el8_9.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-7.el7.x86_64
file /usr/lib64/engines-1.1/capi.so from install of openssl-libs-1:1.1.1k-12.el8_9.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-7.el7.x86_64
file /usr/lib64/engines-1.1/padlock.so from install of openssl-libs-1:1.1.1k-12.el8_9.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-7.el7.x86_64
file /usr/lib64/libcrypto.so.1.1.1k from install of openssl-libs-1:1.1.1k-12.el8_9.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-7.el7.x86_64
file /usr/lib64/libssl.so.1.1.1k from install of openssl-libs-1:1.1.1k-12.el8_9.x86_64 conflicts with file from package openssl11-libs-1:1.1.1k-7.el7.x86_64
file /usr/sbin/pidof from install of procps-ng-3.3.15-14.el8.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
file /usr/bin/last from install of util-linux-2.32.1-44.el8_9.1.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
file /usr/bin/mesg from install of util-linux-2.32.1-44.el8_9.1.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
file /usr/bin/wall from install of util-linux-2.32.1-44.el8_9.1.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
file /usr/share/man/man1/last.1.gz from install of util-linux-2.32.1-44.el8_9.1.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
file /usr/share/man/man1/mesg.1.gz from install of util-linux-2.32.1-44.el8_9.1.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
file /usr/share/man/man1/wall.1.gz from install of util-linux-2.32.1-44.el8_9.1.x86_64 conflicts with file from package sysvinit-tools-2.88-14.dsf.el7.x86_64
解决
dnf remove sysvinit-tools openssl11-libs
再次尝试升级
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
如果还有依赖报错,根据提示卸载相关软件包即可。(如果卸载的软件是你需要用到的,记下删除的软件包名称,升级完成后再装回去就行)
安装内核
dnf install kernel
安装最小化环境
# 这一步选择性执行,执行这一步能解决安装yum报错。
rm -rf /etc/yum
# 安装最小化环境
dnf -y groupinstall "Minimal Install"
修复配置冲突
dnf install rpmconf
#执行rpmconf,如果出现一些提示,请输入Y和回车继续
rpmconf -a
修复引导
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda
卸载el7遗留软件包
rpm -qa | grep '\.el7' # 查看包
rpm -qa | grep '\.el7' | xargs xargs rpm -e # 卸载
重启
reboot
8 升 9
安装 Rocky Linux 9 软件源
# 9.4
rpm -Uvh --nodeps https://mirrors.aliyun.com/rockylinux/9/BaseOS/x86_64/os/Packages/r/rocky-gpg-keys-9.4-1.7.el9.noarch.rpm
rpm -Uvh --nodeps https://mirrors.aliyun.com/rockylinux/9/BaseOS/x86_64/os/Packages/r/rocky-release-9.4-1.7.el9.noarch.rpm
rpm -Uvh --nodeps https://mirrors.aliyun.com/rockylinux/9/BaseOS/x86_64/os/Packages/r/rocky-repos-9.4-1.7.el9.noarch.rpm
# 升级epel源
dnf -y upgrade https://mirrors.aliyun.com/epel/epel-release-latest-9.noarch.rpm
# 执行成功,但是有报错,需要解决下报错
模块依赖问题:
问题 1: 冲突的请求
- nothing provides module(platform:el8) needed by module mariadb:10.3:8080020230920001707:fd72936b.x86_64 from @modulefailsafe
问题 2: 冲突的请求
- nothing provides module(platform:el8) needed by module nginx:1.14:8040020210610090123:9f9e2e7e.x86_64 from @modulefailsafe
问题 3: 冲突的请求
- nothing provides module(platform:el8) needed by module perl-IO-Socket-SSL:2.066:8090020231016070024:88fd4976.x86_64 from @modulefailsafe
- nothing provides module(perl:5.26) needed by module perl-IO-Socket-SSL:2.066:8090020231016070024:88fd4976.x86_64 from @modulefailsafe
问题 4: 冲突的请求
- nothing provides module(platform:el8) needed by module perl-libwww-perl:6.34:8090020231016070052:8af8375c.x86_64 from @modulefailsafe
- nothing provides module(perl:5.26) needed by module perl-libwww-perl:6.34:8090020231016070052:8af8375c.x86_64 from @modulefailsafe
问题 5: 冲突的请求
- nothing provides module(platform:el8) needed by module python27:2.7:8090020231117235334:449e760b.x86_64 from @modulefailsafe
问题 6: 冲突的请求
- nothing provides module(platform:el8) needed by module python36:3.6:8090020231214163110:ed68999d.x86_64 from @modulefailsafe
# 禁用这些报错的依赖
dnf module disable mariadb:10.3 nginx:1.14 perl-IO-Socket-SSL:2.066 perl-libwww-perl:6.34 python27:2.7 python36:3.6
执行升级
dnf -y --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync
重建数据库,解决安装软件报错
rpm --rebuilddb
安装最小化环境
dnf group install minimal-environment -y
解决配置冲突
# 执行rpmconf ,如果出现一些提示,请输入Y和回车继续
rpmconf -a
修复引导
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda
允许root登录
# rocky linux 9 默认禁止root用户远程登录
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
卸载el8遗留软件包
rpm -qa | grep '\.el8' # 查看包
rpm -qa | grep '\.el8' | xargs xargs rpm -e # 卸载
# 如果报依赖错误,可以先卸载依赖包,卸载el8的包后再安装回来
# 如:报错ebtables被firewalld依赖,那么先卸载firewalld,等卸载el8所有的包之后,再把firewalld安装回来
# error: Failed dependencies:
# ebtables is needed by (installed) firewalld-1.2.5-2.el9_3.noarch
重启
reboot
# 可能会报错
Failed to set wall message, ignoring: Failed to activate service 'org.freedesktop.login1': timed out (service_start_timeout=25000ms)
Call to Reboot failed: 连接超时
# 可忽略,实际上是重启成功了
软件源失效了
已修改。如果再遇到软件源失效的问题,一般都是软件包版本更新导致的,可以自行解决。
只需要访问软件源站点,找到最新的版本号即可。
如:https://mirrors.aliyun.com/rockylinux/8/BaseOS/x86_64/os/Packages/r/rocky-release-8.10-1.9.el8.noarch.rpm 过一段时间后版本更新了,这个链接就不对了。只需要访问https://mirrors.aliyun.com/rockylinux/8/BaseOS/x86_64/os/Packages/r/ 即可查看到最新的包版本。
其它包同理。