緣起
一系列服務直接從
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
-
阻止xxx程式通路xxx檔案。SELinux
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