我在用本教程作为获取设置参考Tomcat 8正在运行CentOs 7.1,但输入以下内容后:
[root@localhost tomcat]# sudo systemctl start tomcat
我收到错误:
Job for tomcat.service failed. See 'systemctl status tomcat.service' and 'journalctl -xn' for details.
systemctl status tomcat.service
打印以下内容:
[root@localhost tomcat]# systemctl status tomcat.service
tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled)
Active: failed (Result: exit-code) since Wed 2015-11-25 16:54:33 CET; 1min 19s ago
Process: 45873 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=203/EXEC)
Nov 25 16:54:33 localhost.localdomain systemd[1]: Starting Apache Tomcat Web Application Container...
Nov 25 16:54:33 localhost.localdomain systemd[1]: tomcat.service: control process exited, code=exited status=203
Nov 25 16:54:33 localhost.localdomain systemd[1]: Failed to start Apache Tomcat Web Application Container.
Nov 25 16:54:33 localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.
journalctl -xn
打印以下内容:
[root@localhost tomcat]# journalctl -xn
-- Logs begin at Wed 2015-11-25 13:50:17 CET, end at Wed 2015-11-25 16:54:33 CET. --
Nov 25 16:50:41 localhost.localdomain systemd[1]: Starting PostgreSQL database server...
-- Subject: Unit postgresql.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postgresql.service has begun starting up.
Nov 25 16:50:42 localhost.localdomain systemd[1]: Started PostgreSQL database server.
-- Subject: Unit postgresql.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postgresql.service has finished starting up.
--
-- The start-up result is done.
Nov 25 16:50:58 localhost.localdomain sshd[39118]: pam_unix(sshd:session): session closed for user demo01
Nov 25 16:50:58 localhost.localdomain systemd-logind[631]: Removed session 44.
-- Subject: A session 44 has been terminated
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A session with the ID 44 has been terminated.
Nov 25 16:54:33 localhost.localdomain sudo[45870]: root : TTY=pts/7 ; PWD=/opt/tomcat ; USER=root ; COMMAND=/bin/systemctl star
Nov 25 16:54:33 localhost.localdomain systemd[1]: Starting Apache Tomcat Web Application Container...
-- Subject: Unit tomcat.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat.service has begun starting up.
Nov 25 16:54:33 localhost.localdomain systemd[45873]: Failed at step EXEC spawning /opt/tomcat/bin/startup.sh: Permission denie
-- Subject: Process /opt/tomcat/bin/startup.sh could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /opt/tomcat/bin/startup.sh could not be executed and failed.
--
-- The error number returned while executing this process is 13.
Nov 25 16:54:33 localhost.localdomain systemd[1]: tomcat.service: control process exited, code=exited status=203
Nov 25 16:54:33 localhost.localdomain systemd[1]: Failed to start Apache Tomcat Web Application Container.
-- Subject: Unit tomcat.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tomcat.service has failed.
--
-- The result is failed.
Nov 25 16:54:33 localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.
这个错误是什么意思?如何让我的 CentOs 7.1 服务器上运行 Tomcat 8?
答案1
我刚刚回复了这里我遇到了同样的问题并通过以下方式修复:
赋予 tomcat 用户整个
tomcat
目录的所有权:cd /opt && sudo chown -R tomcat tomcat/
并注释掉以下行
/etc/systemd/system/tomcat.service
:Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
希望能帮助到你。
答案2
在我的例子中,JAVA_HOME 变量总是自动附加“/bin/java”,所以如果我写完整路径,我得到../bin/bin/java
删除“/bin/java”对我来说解决了这个问题。
答案3
在我的情况下,授予 bin 文件夹执行权限解决了我的问题
chmod 755 bin/