缘起
一系列服务直接从 Ubuntu
迁移至 openEuler
后, 发现很多Systemd
服务启动失败。 报错(code=exited, status=203/EXEC)
。
通过检查系统日志tail -f /var/log/messages
发现以下关键信息:
- systemd 执行xxx程序 权限拒绝。
systemd[5646]: xxx.service: Failed to locate executable /root/server/xxx/xxx: Permission denied
SELinux
阻止xxx程序访问xxx文件。
setroubleshoot[5649]: SELinux is preventing (xxx) from execute access on the file xxx. For complete SELinux messages run: sealert -l xxxxx
由于在本地环境相对安全,为了使服务立即上线,这里简单粗暴地直接关闭 SELinux
和 Firewall
。
防火墙 Firewall
查看防火墙状态
有两种方式:
-
执行命令
firewall-cmd --state
运行中running
未启用
not running
-
执行命令
systemctl status firewalld.service
运行中
Active: active (running)
未启用
Active: inactive (dead)
关闭防火墙
- 关闭防火墙服务
systemctl stop firewalld.service
- 关闭防火墙开机自启
systemctl disable firewalld.service
SELinux
查看SELinux状态
-
使用命令
SELinux
启用
Enforcing
如果违反安全策略, 不会拒绝操作,仅记录日志。
Permissive
未启用
Disabled
关闭 SELinux
- 编辑配置文件
vim /etc/selinux/config
, 将SELINUX=enforcing
改为SELINUX=disabled
。 - 重启生效
shutdown -r now