迁移后检查清单
完成从 CentOS 到 AlmaLinux 或 Rocky Linux 的迁移后,按照以下清单逐项验证,确保系统正常工作。
建议: 将本页加入书签,迁移后逐项核对。每完成一项检查后在自己的文档中标记为已完成。
1. 验证操作系统版本
Section titled “1. 验证操作系统版本”首先确认系统已成功切换到目标发行版。
$ cat /etc/os-release确认 NAME 和 ID 字段显示正确的发行版名称(AlmaLinux 或 Rocky Linux)。
$ cat /etc/redhat-release$ rpm -qa | grep -E '(almalinux|rocky)-release'$ rpm -qa | grep centos-release如果仍有 CentOS 包残留:
$ sudo dnf remove centos-release centos-logos centos-indexhtml 2>/dev/null$ sudo dnf distro-sync -y2. 验证内核版本
Section titled “2. 验证内核版本”$ uname -r$ rpm -qa kernel-core | sort$ sudo grubby --default-kernel确保运行的内核来自目标发行版。如果仍在使用旧内核:
$ sudo dnf install -y kernel$ sudo grubby --set-default /boot/vmlinuz-$(rpm -q kernel-core --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -V | tail -1)3. 检查运行中的服务
Section titled “3. 检查运行中的服务”$ systemctl list-units --type=service --state=failed如果有服务失败,逐一排查:
$ systemctl status <服务名>$ journalctl -u <服务名> -n 50 --no-pager$ systemctl list-units --type=service --state=running > ~/services-after-migration.txt$ diff ~/services-before-migration.txt ~/services-after-migration.txt关键服务逐项检查
Section titled “关键服务逐项检查”$ systemctl is-active sshd$ systemctl is-active crond$ systemctl is-active rsyslog$ systemctl is-active firewalld4. 验证软件仓库
Section titled “4. 验证软件仓库”$ dnf repolist --enabled确认仓库指向正确的发行版。不应该有残留的 CentOS 仓库。
$ ls /etc/yum.repos.d/ | grep -i centos$ sudo dnf check-update$ dnf repolist | grep epel如果 EPEL 不存在但需要使用:
$ sudo dnf install -y epel-release5. 测试应用程序
Section titled “5. 测试应用程序”Web 服务
Section titled “Web 服务”$ systemctl is-active nginx && curl -s -o /dev/null -w "%{http_code}" http://localhost/$ systemctl is-active httpd && curl -s -o /dev/null -w "%{http_code}" http://localhost/$ systemctl is-active mariadb || systemctl is-active mysqld$ mysqladmin ping 2>/dev/null && echo "数据库连接正常"$ systemctl is-active postgresql$ sudo -u postgres psql -c "SELECT version();" 2>/dev/null编程语言运行时
Section titled “编程语言运行时”$ php -v 2>/dev/null$ python3 --version$ java -version 2>/dev/null对于自建应用程序,执行以下检查:
$ sudo ss -tlnp | grep <应用端口>$ curl -s http://localhost:<端口>/health6. SELinux 状态
Section titled “6. SELinux 状态”$ getenforce正常情况下应返回 Enforcing。如果返回 Disabled 或 Permissive,需要确认这是否是预期的配置。
$ cat /etc/selinux/config$ sudo ausearch -m avc -ts recent 2>/dev/null | head -30迁移后某些文件的 SELinux 标签可能不正确:
$ sudo fixfiles -F onboot这会在下次重启时重新标记整个文件系统。如果不想重启:
$ sudo restorecon -Rv /etc /var /home7. 防火墙规则
Section titled “7. 防火墙规则”$ sudo firewall-cmd --state$ sudo firewall-cmd --list-all$ sudo firewall-cmd --query-port=22/tcp # SSH$ sudo firewall-cmd --query-port=80/tcp # HTTP$ sudo firewall-cmd --query-port=443/tcp # HTTPS对比迁移前的防火墙配置:
$ sudo firewall-cmd --list-all-zones | grep -A 10 "active"8. 网络配置
Section titled “8. 网络配置”$ ip addr show$ ip route show default$ cat /etc/resolv.conf$ dig +short google.com$ ping -c 3 8.8.8.8$ nmcli connection show$ hostnamectl9. 定时任务
Section titled “9. 定时任务”$ sudo crontab -l$ ls -la /etc/cron.d/$ ls -la /etc/cron.daily/$ ls -la /etc/cron.weekly/$ systemctl list-timers --all10. 备份验证
Section titled “10. 备份验证”确认迁移后备份系统仍然正常工作。
$ which rsync && rsync --version | head -1$ sudo lvs重要提示: 迁移成功并验证无误后,建议立即创建一份新的完整备份作为新的基线。
$ rpm -qa --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort > ~/packages-after-migration-verified.txt11. 系统更新
Section titled “11. 系统更新”确认系统能正常接收更新:
$ sudo dnf check-update$ sudo dnf update -y$ sudo needs-restarting -r && echo "无需重启" || echo "需要重启以应用内核更新"快速检查脚本
Section titled “快速检查脚本”以下脚本可以一次性完成大部分检查并输出报告:
$ echo "===== 系统版本 ====="$ cat /etc/redhat-release$ echo ""$ echo "===== 内核版本 ====="$ uname -r$ echo ""$ echo "===== SELinux 状态 ====="$ getenforce$ echo ""$ echo "===== 失败的服务 ====="$ systemctl list-units --type=service --state=failed --no-legend$ echo ""$ echo "===== 已启用的仓库 ====="$ dnf repolist --enabled 2>/dev/null$ echo ""$ echo "===== 防火墙状态 ====="$ sudo firewall-cmd --state 2>/dev/null$ echo ""$ echo "===== 磁盘使用 ====="$ df -h / /boot /var 2>/dev/null$ echo ""$ echo "===== 网络连通性 ====="$ ping -c 1 -W 3 8.8.8.8 >/dev/null 2>&1 && echo "外网连通" || echo "外网不通"$ dig +short google.com >/dev/null 2>&1 && echo "DNS 正常" || echo "DNS 异常"$ echo ""$ echo "===== 残留 CentOS 包 ====="$ rpm -qa | grep -i centos || echo "无残留"- 迁移到 AlmaLinux — AlmaLinux 迁移步骤
- 迁移到 Rocky Linux — Rocky Linux 迁移步骤
- 常见错误速查 — 遇到错误时的快速参考