Ich habe das Problem einmal gelöst, bin aber in einer anderen Umgebung erneut auf dasselbe Problem gestoßen und habe keine Aufzeichnungen geführt. Daher habe ich 2 Stunden lang gekämpft und mir notiert, den dritten Fehler in Zukunft nicht zu wiederholen.
Wenn ich /etc/systemd/system/tomcat.service wie im Beispiel unter (https://weblabo.oscasierra.net/installing-tomcat8-centos7-1/) erstelle, funktioniert es nicht.
File Edit Options Buffers Tools Help
[Unit]
Description=Apache Tomcat 8
After=network.target
[Service]
User=tomcat
Group=tomcat
Type=oneshot
PIDFile=/usr/java/tomcat8/temp/tomcat.pid
RemainAfterExit=yes
ExecStart=/usr/java/tomcat8/bin/startup.sh
ExecStop=/usr/java/tomcat8/bin/shutdown.sh
ExecReStart=/usr/java/tomcat8/bin/shutdown.sh;/usr/java/tomcat8/bin/startup.sh
[Install]
WantedBy=multi-user.target
Übrigens, wenn Sie /usr/java/tomcat8/bin/startup.sh manuell ausführen, funktioniert es einwandfrei.
[root@localhost ~]# systemctl start tomcat
Job for tomcat.service failed because the control process exited with error code.
See "systemctl status tomcat.service" and "journalctl -xe" for details.
11. August 23:47:39 localhost.localdomain systemd[1]: Starting Apache Tomcat 8...
-- Subject: Unit tomcat.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit tomcat.service has begun starting up.
11. August 23:47:39 localhost.localdomain systemd[2079]: tomcat.service: Failed to execute command: Permission denied
11. August 23:47:39 localhost.localdomain systemd[2079]: tomcat.service: Failed at step EXEC spawning /usr/java/tomcat8/bin/startup.sh: Permission denied
-- Subject: Process /usr/java/tomcat8/bin/startup.sh could not be executed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- The process /usr/java/tomcat8/bin/startup.sh could not be executed and failed.
--
-- The error number returned by this process is 13.
11. August 23:47:39 localhost.localdomain systemd[1]: tomcat.service: Main process exited, code=exited, status=203/EXEC
11. August 23:47:39 localhost.localdomain systemd[1]: tomcat.service: Failed with result 'exit-code'.
11. August 23:47:39 localhost.localdomain systemd[1]: Failed to start Apache Tomcat 8.
-- Subject: Unit tomcat.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit tomcat.service has failed.
--
-- The result is failed.
Sie können auf https://stackoverflow.com/questions/53994521/tomcat-8-on-centos-7-does-not-start-as-service-but-it-starts-manually verweisen.
Die Einstellung, die endlich funktioniert hat. Ist das Arbeitsverzeichnis, wie in der obigen URL erwähnt, doch verdächtig?
/etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat 8
After=network.target
[Service]
Type=forking
WorkingDirectory=/usr/java/tomcat8/bin
ExecStart=/bin/bash /usr/java/tomcat8/bin/catalina.sh start
ExecStop=/bin/bash /usr/java/tomcat8/bin/catalina.sh stop
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target
Recommended Posts