Tomcat8无法在Windows Host上的VirtualBox Vagrant中以Ubuntu 16.04启动

问题描述 投票:2回答:1

我不是很熟悉vagrant并且有一个Ubuntu 16.04的映像,其中包含一个设置并运行tomcat8服务器应用程序的ansible脚本。我在Windows主机上进行了设置,每次都无法启动tomcat服务。

运行ansible playbook的结果是:

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"]}

试图运行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.

通过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'.

我尝试用apt-get重新安装tomcat8,然后用prerm抛出错误,然后postinst,所以我删除了所有tomcat8.prerm,tomcat8.preinst,tomcat8.postinst等文件并再次尝试没有运气。 (老实说不记得确切的结果 - 如果需要我可以再试一次并更新这篇文章)

我还尝试在运行ansible playbook之前手动安装tomcat8,同样的事情发生了。

我只是觉得我刚刚采取疯狂的刺,我不确定从哪里开始挖深,所以任何和所有的想法都非常感激。

更新:当它在macOS主机上运行时结果,不会发生此错误。

更新第2部分:我在剧本中追踪了问题孩子:

- name: Configure tomcat memory
template:
  src: /home/vagrant/shared/resources/tomcat8
  dest: /etc/default/tomcat8
  mode: 0640
  force: True

如果我从剧本中删除它,则不会发生此错误。我不认为它与tomcat8文件的内容有关,因为我试图基本上注释掉所有行以返回默认值并仍然有问题。我猜它可能与权限相关吗?尽管如此,这是它正在复制的文件中的内容:

# 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
windows ubuntu ansible vagrant tomcat8
1个回答
0
投票

问题很可能是systemd模块中的错误JAVA_HOME路径。检查/etc/systemd/system/tomcat.service中的JAVA_HOME路径,它的末尾不应该有“jre /”,这对于较新的Java版本是错误的。尝试:

sudo nano /etc/systemd/system/tomcat.service 

并删除JAVA_HOME路径的尾随“jre /”。然后重启tomcat

sudo systemctl daemon-reload
sudo systemctl restart tomcat
© www.soinside.com 2019 - 2024. All rights reserved.