【问题标题】:Tomcat8 failing to start in Ubuntu 16.04 in VirtualBox Vagrant on Windows HostTomcat8 无法在 Windows 主机上的 VirtualBox Vagrant 中的 Ubuntu 16.04 中启动
【发布时间】:2019-02-04 16:21:40
【问题描述】:

我对 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

【问题讨论】:

  • 您的配置文件中有错误。运行sudo journalctl -xe
  • @AndreiLupuleasa 运行 sudo journalctl -xe 不是很有用。我基本上得到与sudo service tomcat8 status 相同的输出。我不认为这是配置文件中的错误(尽管我不是说不可能)的原因是因为我已经在三个单独的 Mac 主机上完成了完全相同的设置并且没有遇到这个问题,但是它确实出现在我尝试过的两台 Windows 主机上。

标签: windows ubuntu ansible vagrant tomcat8


【解决方案1】:

问题很可能是 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

【讨论】:

  • tomcat.service 文件不存在(该目录中没有任何与 tomcat 相关的内容)。我确实更改了上面粘贴的 tomcat 配置文件,以明确说明 jdk 的正确路径,但没有任何区别。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-05
  • 1970-01-01
  • 2017-06-28
  • 2017-01-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多