定位瓶颈
systemd-analyze 查看总耗时;systemd-analyze blame 按耗时排序服务;systemd-analyze critical-chain <service> 查看关键依赖链。df -h 看根分区是否空间不足;关注硬件故障、资源紧张、文件系统错误、恶意软件等常见诱因。快速优化动作
systemctl list-unit-files --type=service --state=enabled 列出已启用服务;对明显非必要的服务执行 systemctl disable <name>。/etc/default/grub,将 GRUB_TIMEOUT=1(或 0 直接跳过菜单),然后生成配置:grub2-mkconfig -o /boot/grub2/grub.cfggrub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg/etc/ssh/sshd_config,将 GSSAPIAuthentication no、UseDNS no,然后 systemctl restart sshd。/etc/fstab 中挂载选项追加 noatime),减少访问时间更新带来的写放大。/etc/sysctl.conf 设置 vm.swappiness=10(或更低),按需再执行 sysctl -p,减少不必要的 swap 倾向。journalctl --vacuum-time 7d、systemd-tmpfiles --clean,避免日志膨胀影响 I/O。进阶优化与注意事项
setenforce 0;更稳妥的做法是保持 SELINUX=enforcing,通过 ausearch/aureport 与策略调优解决权限导致的慢启动。