linux Tomcat9在步骤NAMESPACE失败

x7yiwoj4  于 2023-06-21  发布在  Linux
关注(0)|答案(3)|浏览(157)

我的操作系统是Debian 10(Buster),4.19内核,Tomcat 9似乎不稳定。
我不希望在运行“systemctl status tomcat9.service”命令时看到任何错误消息。
但是,“systemctl status tomcat9.service”命令打印错误消息。

● tomcat9.service - Apache Tomcat 9 Web Application Server
   Loaded: loaded (/lib/systemd/system/tomcat9.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2020-03-03 21:02:15 KST; 12min ago
     Docs: https://tomcat.apache.org/tomcat-9.0-doc/index.html
  Process: 25999 ExecStartPre=/usr/libexec/tomcat9/tomcat-update-policy.sh (code=exited, status=226/NAMESPACE)

Mar 03 21:02:15 doonas.com systemd[1]: Starting Apache Tomcat 9 Web Application Server...
Mar 03 21:02:15 doonas.com systemd[25999]: tomcat9.service: Failed to set up mount namespacing: No such file or directory
Mar 03 21:02:15 doonas.com systemd[25999]: tomcat9.service: Failed at step NAMESPACE spawning /usr/libexec/tomcat9/tomcat-update-policy.sh
Mar 03 21:02:15 doonas.com systemd[1]: tomcat9.service: Control process exited, code=exited, status=226/NAMESPACE
Mar 03 21:02:15 doonas.com systemd[1]: tomcat9.service: Failed with result 'exit-code'.
Mar 03 21:02:15 doonas.com systemd[1]: Failed to start Apache Tomcat 9 Web Application Server.

但是,尽管有错误信息,我已经确认网页工作正常。
我不知道为什么会这样
我试图解决这个问题。

  1. shutdown.sh、startup.sh已激活。
    但还是不行
root@doonas:/usr/share/tomcat9/bin# bash shutdown.sh
Using CATALINA_BASE:   /usr/share/tomcat9
Using CATALINA_HOME:   /usr/share/tomcat9
Using CATALINA_TMPDIR: /usr/share/tomcat9/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar
NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/jav                                                                                     a.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Mar 03, 2020 9:14:13 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: No shutdown port configured. Shut down server through OS signal. Server not shut down.
root@doonas:/usr/share/tomcat9/bin# bash startup.sh
Using CATALINA_BASE:   /usr/share/tomcat9
Using CATALINA_HOME:   /usr/share/tomcat9
Using CATALINA_TMPDIR: /usr/share/tomcat9/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar
Tomcat started.

1.我通过引用this link修改了符号链接。
他说“Tomcat被systemd沙箱化了,只能对以下目录进行写访问”
但还是不行

root@doonas:/var/lib/tomcat9# ls -l
total 12
drwxr-xr-x 2 root   root   4096 Mar  3 21:00 conf
drwxr-xr-x 2 tomcat tomcat 4096 Jun 14  2019 lib
lrwxrwxrwx 1 root   root     16 Mar  3 20:48 logs -> /var/log/tomcat9
drwxr-xr-x 2 root   root   4096 Feb 18 13:31 policy
lrwxrwxrwx 1 root   root     19 Mar  3 20:48 work -> /var/cache/tomcat9/
root@doonas:/var/lib/tomcat9# ls -l conf/Catalina
lrwxrwxrwx 1 root root 21 Mar  3 21:00 conf/Catalina -> /etc/tomcat9/Catalina

这是我的Tomcat 9信息。
Catalina _BASE是/usr/share/tomcat9。

root@doonas:/usr/share/tomcat9# ls -l
total 24
drwxr-xr-x 2 root root 4096 Feb 17 10:37 bin
lrwxrwxrwx 1 root root   13 Mar  3 21:14 conf -> /etc/tomcat9/
-rw-r--r-- 1 root root 1017 Jun  3  2019 default.template
drwxr-xr-x 2 root root 4096 Feb 17 10:37 etc
drwxr-xr-x 2 root root 4096 Feb 17 10:37 lib
-rw-r--r-- 1 root root  133 Apr  1  2019 logrotate.template
lrwxrwxrwx 1 root root   21 Mar  3 21:10 logs -> /var/lib/tomcat9/logs
lrwxrwxrwx 1 root root   23 Mar  3 21:10 policy -> /var/lib/tomcat9/policy
drwxr-xr-x 5 root root 4096 Feb 17 10:37 skel
lrwxrwxrwx 1 root root   21 Mar  3 21:10 work -> /var/lib/tomcat9/work
root@doonas:/usr/share/tomcat9# ls -l /etc/tomcat9/
total 208
drwxrwxr-x 3 root tomcat   4096 Feb 18 13:26 Catalina
-rw-r----- 1 root tomcat   7483 Feb  4  2019 catalina.properties
-rw-r----- 1 root tomcat   1400 Jul  5  2017 context.xml
-rw-r----- 1 root tomcat   1149 Nov 21  2017 jaspic-providers.xml
-rw-r----- 1 root tomcat   2799 Jun 14  2019 logging.properties
drwxr-xr-x 2 root tomcat   4096 Feb 17 10:37 policy.d
-rw-r----- 1 root tomcat   7638 Feb 18 13:08 server.xml
-rw-r----- 1 root tomcat   2286 Feb 18 10:49 tomcat-users.xml
-rw-r----- 1 root tomcat 170202 Nov 18  2017 web.xml
root@doonas:/usr/share/tomcat9# ls -l /var/lib/tomcat9/
total 12
drwxr-xr-x 2 root   root   4096 Mar  3 21:00 conf
drwxr-xr-x 2 tomcat tomcat 4096 Jun 14  2019 lib
lrwxrwxrwx 1 root   root     16 Mar  3 20:48 logs -> /var/log/tomcat9
drwxr-xr-x 2 root   root   4096 Feb 18 13:31 policy
lrwxrwxrwx 1 root   root     19 Mar  3 20:48 work -> /var/cache/tomcat9/
root@doonas:/usr/share/tomcat9# ls -l /etc/tomcat9/
Catalina/             context.xml           logging.properties    server.xml            web.xml
catalina.properties   jaspic-providers.xml  policy.d/             tomcat-users.xml
m3eecexj

m3eecexj1#

错误消息不是来自tomcat,而是来自systemd。此非特定消息(GitHub Issue 10972)已通过Systemd 243修复。
问题是什么:在单元文件中指定了选项ReadWritePath=,但文件夹/路径不存在。
要修复此问题,请运行systemctl cat tomcat9以获取单元文件的完整内容以及所有可能存在的覆盖文件。然后用ReadWritePath=检查所有行,确保指定的目录确实存在。

mwg9r5ms

mwg9r5ms2#

我在LXC容器中使用Tomcat时遇到了同样的问题。根据Alex's answer,我验证了所有ReadWritePath都存在,但仍然没有帮助。
出于某种原因,在LXC中启用嵌套有帮助(source)。
如果你使用Proxmox,你可以像这样启用它:

pct set <id> -features nesting=1
5jvtdoz2

5jvtdoz23#

我也遇到了同样的问题,Tomcat9。在我的例子中,boggus ReadWritePaths文件路径在以下文件中定义:

/etc/systemd/system/tomcat9.service.d/override.conf

我删除了boggus路径,然后运行以下命令:

sudo systemctl daemon-reload
sudo service tomcat9 restart

相关问题