服务开机启动(code=exited, status=203/EXEC)错误,由于SELinux 开启安全模式

开机自启动配置:

在网上看了好多关于 出现 (code=exited, status=203/EXEC)错误的原因,主要有以下几点:

原因1 :systemctl执行脚本时需要知道脚本的解释器

原因2:目标目录的执行权限不够

原因3:要执行的脚本编码格式不正确

原因4:定义的workingdirectory路径有问题

参考连接:定义服务开机启动code=exited status=203/exec 错误 systemctl 自定义service执行shell脚本时报错code exited status 203 EXEC_(code=exited, status=203/exec)-CSDN博客

bug,以上问题都不是我出现问题的真正原因,我碰到的是 由于SELinux 开启安全模式(SELinux 主要作用就是最大限度地减小系统中服务进程可访问的资源)导致不能设置开机自启动service

如何关闭 SELinux:

        两种办法,如果系统无法立刻关闭,建议 先设置临时,同时也去修改配置文件关闭,待合适时机重启服务器

  临时关闭:

[root@SHD-SVR-V3 bin]# getenforce   #查看selinux状态
Enforcing

[root@SHD-SVR-V3 bin]# setenforce 0  #临时关闭selinux

[root@SHD-SVR-V3 bin]# getenforce
Permissive

永久关闭(需要重启):

[root@SHD-SVR-V3 bin]# vi /etc/selinux/config

SELINUX=enforcing 修改为  SELINUX=disabled
#重启服务器生效

设置好,再去执行 

[root@SHD-SVR-V3 bin]# systemctl start node_exporter
[root@SHD-SVR-V3 bin]# systemctl status node_exporter
● node_exporter.service - node_exporter Monitoring System
   Loaded: loaded (/etc/systemd/system/node_exporter.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2024-01-03 17:06:38 CST; 7s ago
 Main PID: 467456 (node_exporter)
    Tasks: 5 (limit: 101075)
   Memory: 7.4M
   CGroup: /system.slice/node_exporter.service
           └─467456 /usr/local/bin/node_exporter --web.listen-address=:9100

  • 9
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值