[英]Tomcat8 failing to start in Ubuntu 16.04 in VirtualBox Vagrant on Windows Host
I'm not super familiar with vagrant and have an image for Ubuntu 16.04 with an ansible script that sets up and runs a tomcat8 server application. 我对流浪者不是很熟悉,并且对Ubuntu 16.04有一个使用ansible脚本的映像,该脚本设置并运行了tomcat8服务器应用程序。 I went to set it up on a Windows host, and the tomcat service fails to start every time.
我去在Windows主机上设置它,并且tomcat服务每次都无法启动。
The result of running the ansible playbook is: 运行ansible剧本的结果是:
TASK [Restart tomcat] **********************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": "service tomcat8 restart", "delta": "0:00:00.046020", "end": "2019-02-02 17:55:28.417905", "failed": true, "rc": 1, "start": "2019-02-02 17:55:28.371885", "stderr": "Job for tomcat8.service failed because the control process exited with error code. See \"systemctl status tomcat8.service\" and \"journalctl -xe\" for details.", "stdout": "", "stdout_lines": [], "warnings": ["Consider using service module rather than running service"]}
The result of trying to run sudo service tomcat8 restart
is: 尝试运行
sudo service tomcat8 restart
是:
Job for tomcat8.service failed because the control process exited with error code. See "systemctl status tomcat8.service" and "journalctl -xe" for details.
Checking the service status via sudo service tomcat8 status
gives: 通过
sudo service tomcat8 status
检查服务sudo service tomcat8 status
会给出:
● tomcat8.service - LSB: Start Tomcat.
Loaded: loaded (/etc/init.d/tomcat8; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-02-04 16:15:19 UTC; 46s ago
Docs: man:systemd-sysv-generator(8)
Process: 10703 ExecStop=/etc/init.d/tomcat8 stop (code=exited, status=0/SUCCESS)
Process: 11859 ExecStart=/etc/init.d/tomcat8 start (code=exited, status=127)
Feb 04 16:15:19 vagrant systemd[1]: Starting LSB: Start Tomcat....
Feb 04 16:15:19 vagrant tomcat8[11859]: [58B blob data]
Feb 04 16:15:19 vagrant systemd[1]: tomcat8.service: Control process exited, code=exited status=127
Feb 04 16:15:19 vagrant systemd[1]: Failed to start LSB: Start Tomcat..
Feb 04 16:15:19 vagrant systemd[1]: tomcat8.service: Unit entered failed state.
Feb 04 16:15:19 vagrant systemd[1]: tomcat8.service: Failed with result 'exit-code'.
I have tried reinstalling tomcat8 with apt-get, and that threw errors with prerm, and then postinst, so I removed all of the tomcat8.prerm, tomcat8.preinst, tomcat8.postinst, etc files and tried again with no luck. 我曾尝试使用apt-get重新安装tomcat8,这会在prerm和postinst中引发错误,所以我删除了所有tomcat8.prerm,tomcat8.preinst,tomcat8.postinst等文件,然后再试一次就没有运气了。 (Honestly don't remember the exact result of that - if needed I can try again and update this post)
(老实说,我不记得它的确切结果-如果需要,我可以再试一次并更新这篇文章)
I also tried manually installing tomcat8 before running the ansible playbook and the same thing happened. 我还尝试在运行ansible剧本之前手动安装tomcat8,并且发生了同样的事情。
I just feel like I've just been taking wild stabs and am not sure really where to start digging deep, so any and all ideas are greatly appreciated. 我只是觉得自己一直在冒险,所以不确定从哪里开始深入研究,因此非常感谢所有想法。
UPDATE: Turns out when this runs on a macOS host, this error does not occur.. 更新:原来这是在macOS主机上运行时,不会发生此错误。
UPDATE PART 2: I tracked down the problem child in the playbook: 更新第2部分:我在剧本中找到了问题孩子:
- name: Configure tomcat memory
template:
src: /home/vagrant/shared/resources/tomcat8
dest: /etc/default/tomcat8
mode: 0640
force: True
If I remove that from the playbook, this error doesn't occur. 如果我将其从剧本中删除,则不会发生此错误。 I don't think it's related to the contents of the tomcat8 file, because I tried basically commenting out all the lines to go back to the default and still had the problem.
我认为这与tomcat8文件的内容无关,因为我基本上尝试注释掉所有行以返回默认值,但仍然有问题。 I'm guessing it's something permissions related maybe?
我猜想这可能与权限相关吗? Nonetheless, here's what's in the file it's copying:
尽管如此,这是要复制的文件中的内容:
# Run Tomcat as this user ID. Not setting this or leaving it blank will use the
# default of tomcat8.
TOMCAT8_USER=tomcat8
# Run Tomcat as this group ID. Not setting this or leaving it blank will use
# the default of tomcat8.
TOMCAT8_GROUP=tomcat8
# The home directory of the Java development kit (JDK). You need at least
# JDK version 7. If JAVA_HOME is not set, some common directories for
# OpenJDK and the Oracle JDK are tried.
#JAVA_HOME=/usr/lib/jvm/java-7-openjdk
# You may pass JVM startup parameters to Java here. If unset, the default
# options will be: -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC
#
# Use "-XX:+UseConcMarkSweepGC" to enable the CMS garbage collector (improved
# response time). If you use that option and you run Tomcat on a machine with
# exactly one CPU chip that contains one or two cores, you should also add
# the "-XX:+CMSIncrementalMode" option.
#JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC" # original setting
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx1024m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -Dapp.profile=vm"
# To enable remote debugging uncomment the following line.
# You will then be able to use a java debugger on port 8000.
JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
# Java compiler to use for translating JavaServer Pages (JSPs). You can use all
# compilers that are accepted by Ant's build.compiler property.
#JSP_COMPILER=javac
# Use the Java security manager? (yes/no, default: no)
#TOMCAT8_SECURITY=no
# Number of days to keep logfiles in /var/log/tomcat8. Default is 14 days.
#LOGFILE_DAYS=14
# Whether to compress logfiles older than today's
#LOGFILE_COMPRESS=1
# Location of the JVM temporary directory
# WARNING: This directory will be destroyed and recreated at every startup !
#JVM_TMP=/tmp/tomcat8-temp
# If you run Tomcat on port numbers that are all higher than 1023, then you
# do not need authbind. It is used for binding Tomcat to lower port numbers.
# (yes/no, default: no)
#AUTHBIND=no
#GEOSERVER_DATA_DIR=/efs/geoserver_data
The problem is most likely a wrong JAVA_HOME path inside the systemd module. 问题很可能是systemd模块内的JAVA_HOME路径错误。 Check the JAVA_HOME path inside /etc/systemd/system/tomcat.service, it should not have "jre/" at the end which is wrong for newer Java versions.
检查/etc/systemd/system/tomcat.service中的JAVA_HOME路径,该路径的结尾不应包含“ jre /”,这对于较新的Java版本是错误的。 Try:
尝试:
sudo nano /etc/systemd/system/tomcat.service
and remove the trailing "jre/" of the JAVA_HOME path. 并删除JAVA_HOME路径的结尾“ jre /”。 Then restart tomcat
然后重启tomcat
sudo systemctl daemon-reload
sudo systemctl restart tomcat
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.