【问题标题】:Ubuntu tomcat9 Jenkins setup issueUbuntu tomcat9 Jenkins设置问题
【发布时间】:2020-08-25 01:14:08
【问题描述】:

我一直在尝试在 tomcat9 上安装 Jenkins,但是当我第一次在 http://myip:8080/jenkins 上完成设置时;我有以下错误:

java.io.IOException: Read-only file system
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createTempFile(File.java:2026)
    at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:142)
Caused: java.io.IOException: Failed to create a temporary file in /var/lib/jenkins
    at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:144)
    at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:109)
    at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:84)
    at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:74)
    at hudson.util.TextFile.write(TextFile.java:116)
    at jenkins.model.Jenkins.<init>(Jenkins.java:910)
    at hudson.model.Hudson.<init>(Hudson.java:85)
    at hudson.model.Hudson.<init>(Hudson.java:81)
    at hudson.WebAppMain$3.run(WebAppMain.java:262)
Caused: hudson.util.HudsonFailedToLoad
    at hudson.WebAppMain$3.run(WebAppMain.java:279)

首先:Tomcat9运行良好,我可以本地访问或者remortal 我创建了 /var/lib/jenkins 归 jenkins(我创建的 unix 用户)所有,我什至设置了 777 的权限。

第二:如果我在命令行“java -jar jankins.war”中运行战争(我之前已经导出了 JENKINS_HOME=/var/lib/jenkins),那么 jenkins 可以正常工作。所以战争没有损坏。

第三:在 tomcat 上,我修改了 context.xml 以将 JENKINS_HOME 设置为 /var/lib/jenkins,它正在工作,你可以看到上面的错误(第 5 行)。 然后在 context.xml 中,我尝试将 JENKINS_USER 设置为几个不同的用户(jenkins、tomcat、root 等),我尝试了 /var/lib/jenkins(以及组)的不同所有权。

这是我的 context.xml:

<Context>
    <Environment name="JENKINS_HOME" value="/var/lib/jenkins" type="java.lang.String" />
    <Environment name="JENKINS_USER" value="jenkins" type="java.lang.String" />
    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->
</Context>

但是没有任何效果,看起来 JENKINS_USER 没有被考虑在内和/或无论我做什么目录都是只读的......

注意:正如我所读到的,JDK 版本可能存在一些问题,所以我尝试使用 open-jdk-11(一开始)然后使用 open-jdk-8

有人遇到过这个问题吗?

【问题讨论】:

    标签: jenkins tomcat installation


    【解决方案1】:

    如果您从 Ubuntu 存储库运行 tomcat9,它将以 unix 用户 tomcat 运行。向用户jenkins 提供访问权限不会授予 tomcat 权限。并且仅仅定义任意环境变量(JENKINS_HOMEJENKINS_USER)不会让 Web 应用神奇地改变它的身份。

    tomcat 中的所有 Web 应用程序都以同一个用户身份运行,这就是您需要提供访问权限的用户。

    另外,请注意 Debian 的 Tomcat 在沙盒环境中运行(有关相关问题,请参阅 this answer),因此除了文件/进程的所有者之外,您还需要在沙盒环境中工作。

    【讨论】:

    • 感谢@olaf,感谢您的友好回答。您所写的内容非常合理,实际上这就是我最初所做的,并且由于它不起作用,我尝试了其他解决方案..例如更改用户..无论如何要仔细检查我再次尝试但仍然无法正常工作。顺便说一句,正如我写的那样,我 chmod 777 目录让任何人都可以访问 /var/lib/jenkins 目录,但我仍然有同样的错误。
    • 在这种情况下,您会遇到stackoverflow.com/a/56835997/13447。我也会将其编辑到我的答案中。如果没有不同用户帐户的复杂性,这个问题将是重复的。这样,它为问题添加了一个单独的层,我认为它不是重复的。
    • 是的!非常感谢奥拉夫。我回来了,拥有正常的权限/所有权和正常的行为。
    猜你喜欢
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    • 2012-06-23
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多