码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu18.04上设置Tomcat8开机自启动

时间:2020-02-15 09:21:55      阅读:704      评论:0      收藏:0      [点我收藏+]

标签:cti   RoCE   spawn   Servle   config   virtual   tar   start   process   

参照这篇博客:在Ubuntu 18.04上安装Tomcat 8 并设置自启动 成功了。

但是期间遇到了一个问题:运行命令sudo systemctl start tomcat的时候,报错:

Warning: The unit file, source configuration file or drop-ins of tomcat.service changed on disk. Run 'systemctl daemon-reload' to reload units.
Job for tomcat.service failed because the control process exited with error code.
See "systemctl status tomcat.service" and "journalctl -xe" for details.

使用命令:systemctl status tomcat ,查看状态:

Warning: The unit file, source configuration file or drop-ins of tomcat.service changed on disk. Run 'systemctl daemon-reload' to reload units.
● tomcat.service - Tomcat 8 servlet container
   Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-02-15 00:45:14 CST; 8s ago
  Process: 2834 ExecStart=/usr/local/apache-tomcat-8.5.50/bin/startup.sh (code=exited, status=217/USER)

2月 15 00:45:14 humen-virtual-machine systemd[1]: Starting Tomcat 8 servlet container...
2月 15 00:45:14 humen-virtual-machine systemd[2834]: tomcat.service: Failed to determine user credentials: No such process
2月 15 00:45:14 humen-virtual-machine systemd[2834]: tomcat.service: Failed at step USER spawning /usr/local/apache-tomcat-8.5.50/bin/startup.sh: No such process
2月 15 00:45:14 humen-virtual-machine systemd[1]: tomcat.service: Control process exited, code=exited status=217
2月 15 00:45:14 humen-virtual-machine systemd[1]: tomcat.service: Failed with result 'exit-code'.
2月 15 00:45:14 humen-virtual-machine systemd[1]: Failed to start Tomcat 8 servlet container.

根据No such process,我猜测是tomcat.service文件权限不够,查看,果然是只读:

-rw-r--r--  1 root root  694 2月  15 00:45  tomcat.service

提升权限后重新启动tomcat服务,成功,最后设置开机自启动。

sudo chmod 777 tomcat.service 
humen@humen-virtual-machine:/etc/systemd/system$ sudo systemctl daemon-reload
humen@humen-virtual-machine:/etc/systemd/system$ sudo systemctl start tomcat
humen@humen-virtual-machine:/etc/systemd/system$ systemctl status tomcat
● tomcat.service - Tomcat 8 servlet container
   Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-02-15 00:50:24 CST; 13s ago
  Process: 2885 ExecStart=/usr/local/apache-tomcat-8.5.50/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 2892 (java)
    Tasks: 20 (limit: 4609)
   CGroup: /system.slice/tomcat.service
           └─2892 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.util.logging.config.file=/usr/local/apache-tomcat-8.5.50/conf/logging.properties -Djava.util.logging.manager=org.apach

2月 15 00:50:24 humen-virtual-machine systemd[1]: Starting Tomcat 8 servlet container...
2月 15 00:50:24 humen-virtual-machine startup.sh[2885]: Tomcat started.
2月 15 00:50:24 humen-virtual-machine systemd[1]: Started Tomcat 8 servlet container.
lines 1-12/12 (END)
humen@humen-virtual-machine:/etc/systemd/system$ sudo systemctl enable tomcat
Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.

重启后成功!!!

Ubuntu18.04上设置Tomcat8开机自启动

标签:cti   RoCE   spawn   Servle   config   virtual   tar   start   process   

原文地址:https://www.cnblogs.com/yxqxx/p/12310440.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!