Tomcat catalina.sh 正确启动,但启动 tomcat.service 给出 Permission returned

Tomcat catalina.sh 正确启动,但启动 tomcat.service 给出 Permission returned

背景

在 RHEL 8 上,我在 下安装了 Apache Tomcat v8.5.78 /opt/tomcat/。目录的用户和组设置为tomcat:tomcat,目录的内容也是如此。

我可以启动 Tomcat

$ sudo -u tomcat /opt/tomcat/bin/catalina.sh start

现在我尝试通过systemctl.我有一个tomcat.service这样的文件:

[Unit]
Description=Tomcat Server
After=syslog.target network.target

[Service]
Type=forking
User=tomcat
Group=tomcat

Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment='JAVA_OPTS=-Djava.awt.headless=true'
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment='CATALINA_OPTS=-Xms512M -Xmx2048M'
ExecStart=/opt/tomcat/bin/catalina.sh start
ExecStop=/opt/tomcat/bin/catalina.sh stop

[Install]
WantedBy=multi-user.target

请注意,服务用户和组也设置为tomcat& 。tomcat

问题

当我通过 systemctl 启动 Tomcat 时:

$ sudo systemctl start tomcat.service

我收到“tomcat.service 作业失败...”。systemctl status tomcat.service节目

● tomcat.service - Tomcat Server
   Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2022-06-22 12:11:59 AEST; 1min 29s ago
  Process: 1641092 ExecStart=/opt/tomcat/bin/catalina.sh start (code=exited, status=203/EXEC)

journalctl -xe给出:

-- Unit tomcat.service has begun starting up.
Jun 22 11:41:47 my.server.local systemd[1638136]: tomcat.service: Failed to execute command: Permission denied
Jun 22 11:41:47 my.server.local systemd[1638136]: tomcat.service: Failed at step EXEC spawning /opt/tomcat/bin/catalina.sh: Permission d>-- Subject: Process /opt/tomcat/bin/catalina.sh could not be executed

systemctl当服务文件指定与手动启动相同的用户时,为什么会报告权限问题?

附加信息

汤姆猫版本

Tomcat 版本是必需的 - 我无法升级到较新的版本。

我还尝试过什么?

  1. 读过https://unix.stackexchange.com/a/498494/45940我在tomcat.service指令中尝试过Type=oneshot——但没有成功。

  2. 读过https://stackoverflow.com/a/58301082/65889tomcat.service我尝试将工作目录设置为/opt/tomcat/bin-- 但没有成功

答案1

就我而言,这是目录.sh中的文件权限/bin。它们都缺少x(可执行)标志。

相关内容