AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 978731
Accepted
Philip Rego
Philip Rego
Asked: 2019-08-11 11:14:53 +0800 CST2019-08-11 11:14:53 +0800 CST 2019-08-11 11:14:53 +0800 CST

如何修复我的 systemctl 状态 tomcat?

  • 772

我怎样才能systemctl status tomcat返回“成功”而不是“失败”?

这是我的 etc/systemd/system/tomcat.service 文件:

    [Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target

[Service]
Type=forking

Environment=JRE_HOME=JAVA_HOME='/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/'
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
#Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID

User=tomcat
Group=tomcat

[Install]
WantedBy=multi-user.target

现在,当我检查我的 tomcat 的状态时,它说

# systemctl status tomcat
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2019-08-10 14:03:10 EDT; 55min ago
 Main PID: 22165 (code=exited, status=127)

Aug 10 14:03:10 localhost.localdomain kill[22167]: -q, --queue <sig>      use sigqueue(2) rather than kill(2)
Aug 10 14:03:10 localhost.localdomain kill[22167]: -p, --pid              print pids without signaling them
Aug 10 14:03:10 localhost.localdomain kill[22167]: -l, --list [=<signal>] list signal names, or convert one to a name
Aug 10 14:03:10 localhost.localdomain kill[22167]: -L, --table            list signal names and numbers
Aug 10 14:03:10 localhost.localdomain kill[22167]: -h, --help     display this help and exit
Aug 10 14:03:10 localhost.localdomain kill[22167]: -V, --version  output version information and exit
Aug 10 14:03:10 localhost.localdomain kill[22167]: For more details see kill(1).
Aug 10 14:03:10 localhost.localdomain systemd[1]: tomcat.service: control process exited, code=exited status=1
Aug 10 14:03:10 localhost.localdomain systemd[1]: Unit tomcat.service entered failed state.
Aug 10 14:03:10 localhost.localdomain systemd[1]: tomcat.service failed.



Caused by: java.net.ConnectException: Connection refused (Connection refused)

我在尝试运行 sudo certbot --apache 时遇到此错误

Error while running apachectl graceful.

Job for httpd.service invalid.

Unable to restart apache using ['apachectl', 'graceful']
Error while running apachectl restart.

Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

Encountered exception during recovery: 
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/certbot/error_handler.py", line 124, in _call_registered
    self.funcs[-1]()
  File "/usr/lib/python2.7/site-packages/certbot/auth_handler.py", line 220, in _cleanup_challenges
    self.auth.cleanup(achalls)
  File "/usr/lib/python2.7/site-packages/certbot_apache/configurator.py", line 2332, in cleanup
    self.restart()
  File "/usr/lib/python2.7/site-packages/certbot_apache/configurator.py", line 2202, in restart
    self._reload()
  File "/usr/lib/python2.7/site-packages/certbot_apache/configurator.py", line 2229, in _reload
    raise errors.MisconfigurationError(error)
MisconfigurationError: Error while running apachectl restart.

Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

这是我的 journalctl -xe: https ://pastebin.com/JvJ8Uej0 这是我的 journalctl -b -u tomcat: https ://pastebin.com/zPqEBGXH

尝试杀死进程但没有工作:

# kill 23656
bash: kill: (23656) - No such process

在此处输入图像描述 这可能是什么原因?如何修复这些错误?该网站运行良好,但我收到了这些错误。

centos
  • 1 1 个回答
  • 29235 Views

1 个回答

  • Voted
  1. Best Answer
    Philip Rego
    2019-08-12T21:47:37+08:002019-08-12T21:47:37+08:00

    我的问题是单元文件中的行:

    Environment=JRE_HOME=JAVA_HOME='/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/'
    

    它应该没有引号:

    Environment=JRE_HOME=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/
    

    我可以通过尝试systemctl restat tomcat然后查看日志来找到这个catalia.out错误,/opt/tomcat/bin/catalina.sh其中的/opt/tomcat/bin/startup.sh调用看起来像是 JAVA_HOME 的错误。

    感谢 djdomi 在评论中帮助我到达那里。

    • 0

相关问题

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 使用 crontab 和 /etc/cron.hourly,daily,weekly 的区别

  • 持续监控许多服务器运行状况的简单方法?

  • Hudson 无法在 tomcat5 中启动

  • CentOS 的依赖挑战

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve