CentOS排查SELinux问题可按以下步骤进行:
getenforce或sestatus确认是否启用及当前模式(Enforcing/Permissive/Disabled)。/var/log/audit/audit.log,用ausearch -m avc过滤SELinux拒绝记录,或通过sealert -a /var/log/audit/audit.log获取可读分析及修复建议。setenforce 0切换为Permissive模式(仅记录违规,不阻止操作),验证是否为SELinux导致的问题。ls -Z查看文件/目录的SELinux上下文,用chcon或restorecon修正错误上下文。semanage port -l查看端口策略。audit2allow根据日志生成自定义策略模块,加载后生效:audit2allow -a -M mypolicy && semodule -i mypolicy.pp。/etc/selinux/config,将SELINUX设为disabled或permissive,重启生效。注意:生产环境谨慎永久禁用,优先通过策略调整解决问题。