CentOS 7 与 Rocky Linux 9.5 运维对比
一、核心系统差异对比
功能模块 | CentOS 7 | Rocky Linux 9.5 | 说明 |
---|
系统基础 | 基于 RHEL 7 | 基于 RHEL 9 | Rocky 9 使用 Kernel 5.14+,支持新硬件和安全性增强 |
软件包管理 | yum (Python 2 实现) | dnf (默认,替代 yum ) | dnf 性能更优,语法兼容但有参数调整(如 dnf history 替代 yum history ) |
Python 环境 | 默认 Python 2.7 | 默认 Python 3.9 | Rocky 9 已移除 Python 2,需检查脚本兼容性 |
网络管理 | network.service + ifcfg 文件 | 默认 NetworkManager (推荐 nmcli /nmtui ) | CentOS 7 的 ifcfg-eth0 仍支持但不推荐 |
防火墙后端 | iptables | nftables (firewalld 默认后端) | iptables 命令在 Rocky 9 中映射到 nftables |
时间同步 | ntpd | chronyd (默认) | Rocky 9 弃用 ntpd ,需迁移到 chrony |
文件系统 | XFS/ext4 | 支持 XFS/Btrfs | Btrfs 提供快照、压缩等高级功能 |
二、关键操作指令对比
1. 软件包管理
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
安装软件包 | yum install httpd | dnf install httpd |
更新所有软件包 | yum update | dnf upgrade |
搜索软件包 | yum search nginx | dnf search nginx |
删除软件包 | yum remove httpd | dnf remove httpd |
查看仓库列表 | yum repolist | dnf repolist |
2. 服务管理
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
重启网络服务 | systemctl restart network | nmcli connection reload + 重启特定连接 |
查看服务状态 | systemctl status firewalld | systemctl status firewalld |
启用新服务 | systemctl enable httpd | systemctl enable httpd |
3. 网络配置
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
查看 IP 地址 | ifconfig (需安装 net-tools ) | ip addr (推荐) |
配置静态 IP | 编辑 /etc/sysconfig/network-scripts/ifcfg-eth0 | 使用 nmtui 或编辑 /etc/NetworkManager/system-connections/ 下的配置文件 |
重启网络 | systemctl restart network | nmcli connection down eth0 && nmcli connection up eth0 |
4. 防火墙管理
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
开放 HTTP 端口 | firewall-cmd --add-service=http --permanent | 同左(后端为 nftables ) |
查看开放端口 | firewall-cmd --list-ports | 同左 |
5. 日志管理
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
查看系统日志 | tail -f /var/log/messages | journalctl -f (统一日志管理) |
过滤服务日志 | grep "error" /var/log/secure | `journalctl -u sshd |
三、CentOS 7 到 Rocky 9.5 的迁移注意事项
1. 弃用指令替代方案
service
命令:
全部替换为 systemctl
(如 service httpd restart
→ systemctl restart httpd
)。ifconfig
:
使用 ip addr
或安装 net-tools
包。iptables-save
:
改用 nft list ruleset
查看当前规则。
2. 配置文件路径变更
- 网络配置:
CentOS 7:/etc/sysconfig/network-scripts/ifcfg-eth0
Rocky 9:/etc/NetworkManager/system-connections/eth0.nmconnection
- DNS 配置:
不再推荐直接修改 /etc/resolv.conf
,应通过 nmcli
修改连接配置。
3. 软件包名称差异
CentOS 7 | Rocky 9.5 | 说明 |
---|
mysql-server | mariadb-server | MariaDB 替代 MySQL |
python | python3 | Python 2 已移除 |
四、Rocky Linux 9.5 新特性
1. 模块化软件仓库
dnf module list nodejs
dnf module enable nodejs:18
2. 安全性增强
- SELinux:提供布尔值,允许 QEMU Guest Agent 执行受限制的命令。
- OpenSSL:升级到 3.2.2,支持证书压缩扩展。
- ca-certificates:以 OpenSSL 目录格式提供受信任的 CA root。
3. 性能与工具更新
- GCC:升级到 11.5。
- GDB:升级到 14.2。
- Podman:升级到 v5.0,支持多架构镜像构建。
4. Web 控制台增强
- 添加
cockpit-files
软件包,支持文件管理。
1. 软件包管理
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
安装软件包 | yum install httpd | dnf install httpd |
更新所有软件包 | yum update | dnf upgrade |
搜索软件包 | yum search nginx | dnf search nginx |
删除软件包 | yum remove httpd | dnf remove httpd |
查看仓库列表 | yum repolist | dnf repolist |
2. 服务管理
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
重启网络服务 | systemctl restart network | nmcli connection reload + 重启特定连接 |
查看服务状态 | systemctl status firewalld | systemctl status firewalld |
启用新服务 | systemctl enable httpd | systemctl enable httpd |
3. 网络配置
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
查看 IP 地址 | ifconfig (需安装 net-tools ) | ip addr (推荐) |
配置静态 IP | 编辑 /etc/sysconfig/network-scripts/ifcfg-eth0 | 使用 nmtui 或编辑 /etc/NetworkManager/system-connections/ 下的配置文件 |
重启网络 | systemctl restart network | nmcli connection down eth0 && nmcli connection up eth0 |
4. 防火墙管理
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
开放 HTTP 端口 | firewall-cmd --add-service=http --permanent | 同左(后端为 nftables ) |
查看开放端口 | firewall-cmd --list-ports | 同左 |
5. 日志管理
操作 | CentOS 7 | Rocky Linux 9.5 |
---|
查看系统日志 | tail -f /var/log/messages | journalctl -f (统一日志管理) |
过滤服务日志 | grep "error" /var/log/secure | `journalctl -u sshd |
三、CentOS 7 到 Rocky 9.5 的迁移注意事项
1. 弃用指令替代方案
service
命令:
全部替换为 systemctl
(如 service httpd restart
→ systemctl restart httpd
)。ifconfig
:
使用 ip addr
或安装 net-tools
包。iptables-save
:
改用 nft list ruleset
查看当前规则。
2. 配置文件路径变更
- 网络配置:
CentOS 7:/etc/sysconfig/network-scripts/ifcfg-eth0
Rocky 9:/etc/NetworkManager/system-connections/eth0.nmconnection
- DNS 配置:
不再推荐直接修改 /etc/resolv.conf
,应通过 nmcli
修改连接配置。
3. 软件包名称差异
CentOS 7 | Rocky 9.5 | 说明 |
---|
mysql-server | mariadb-server | MariaDB 替代 MySQL |
python | python3 | Python 2 已移除 |
四、Rocky Linux 9.5 新特性
1. 模块化软件仓库
dnf module list nodejs
dnf module enable nodejs:18
2. 安全性增强
- SELinux:提供布尔值,允许 QEMU Guest Agent 执行受限制的命令。
- OpenSSL:升级到 3.2.2,支持证书压缩扩展。
- ca-certificates:以 OpenSSL 目录格式提供受信任的 CA root。
3. 性能与工具更新
- GCC:升级到 11.5。
- GDB:升级到 14.2。
- Podman:升级到 v5.0,支持多架构镜像构建。
4. Web 控制台增强
- 添加
cockpit-files
软件包,支持文件管理。