安装 Jenkins,服务失败并显示“超时”

安装 Jenkins,服务失败并显示“超时”

我正在尝试在运行 Ubuntu Server 22.04 的 Raspberry Pi 上安装 jenkins。我按照以下指示进行操作数字海洋但是在安装 Jenkins 时我收到超时错误

> apt install jenkins
...
Do you want to continue? [Y/n] y
(Reading database ... 144296 files and directories currently installed.)
Removing jenkins (2.375.1) ...
(Reading database ... 144287 files and directories currently installed.)
Purging configuration files for jenkins (2.375.1) ...
failed to remove jenkins system user
Scanning processes...
Scanning processor microcode...
Scanning linux images...

Running kernel seems to be up-to-date.

Failed to check for processor microcode upgrades.

Selecting previously unselected package jenkins.
(Reading database ... 144282 files and directories currently installed.)
Preparing to unpack .../jenkins_2.375.1_all.deb ...
Unpacking jenkins (2.375.1) ...
Setting up jenkins (2.375.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /lib/systemd/system/jenkins.service.
Job for jenkins.service failed because a timeout was exceeded.
See "systemctl status jenkins.service" and "journalctl -xeu jenkins.service" for details.
invoke-rc.d: initscript jenkins, action "start" failed.
● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/jenkins.service.d
             └─override.conf
     Active: activating (auto-restart) (Result: timeout) since Fri 2022-12-09 10:27:08 UTC; 23ms ago
    Process: 28644 ExecStart=/usr/bin/jenkins (code=exited, status=143)
   Main PID: 28644 (code=exited, status=143)
     Status: "Jenkins stopped"
        CPU: 4min 30.555s
dpkg: error processing package jenkins (--configure):
 installed jenkins package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 jenkins
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

这是我在 journaclctl 中发现的。它会持续执行此操作。

> journalctl -u jenkins -f
Dec 09 10:17:45 fat-boi systemd[1]: Starting Jenkins Continuous Integration Server...
Dec 09 10:17:47 fat-boi jenkins[27383]: Running from: /usr/share/java/jenkins.war
Dec 09 10:17:48 fat-boi jenkins[27383]: 2022-12-09 10:17:48.016+0000 [id=1]        INFO        winstone.Logger#logInternal: Beginning extraction from war file
Dec 09 10:17:48 fat-boi jenkins[27383]: 2022-12-09 10:17:48.190+0000 [id=1]        WARNING        o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
Dec 09 10:17:48 fat-boi jenkins[27383]: 2022-12-09 10:17:48.484+0000 [id=1]        INFO        org.eclipse.jetty.server.Server#doStart: jetty-10.0.12; built: 2022-09-14T01:54:40.076Z; git: 408d0139887e27a57b54ed52e2d92a36731a7e88; jvm 11.0.17+8-post-Ubuntu-1ubuntu222.04
Dec 09 10:17:49 fat-boi jenkins[27383]: 2022-12-09 10:17:49.984+0000 [id=1]        INFO        o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
Dec 09 10:17:50 fat-boi jenkins[27383]: 2022-12-09 10:17:50.344+0000 [id=1]        INFO        o.e.j.s.s.DefaultSessionIdManager#doStart: Session workerName=node0
Dec 09 10:17:53 fat-boi jenkins[27383]: 2022-12-09 10:17:53.123+0000 [id=1]        INFO        hudson.WebAppMain#contextInitialized: Jenkins home directory: /var/lib/jenkins found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
Dec 09 10:17:54 fat-boi jenkins[27383]: 2022-12-09 10:17:54.137+0000 [id=1]        INFO        o.e.j.s.handler.ContextHandler#doStart: Started w.@4642b71d{Jenkins v2.375.1,/,file:///var/cache/jenkins/war/,AVAILABLE}{/var/cache/jenkins/war}
Dec 09 10:17:54 fat-boi jenkins[27383]: 2022-12-09 10:17:54.199+0000 [id=1]        INFO        o.e.j.server.AbstractConnector#doStart: Started ServerConnector@707194ba{HTTP/1.1, (http/1.1)}{0.0.0.0:8989}
Dec 09 10:17:54 fat-boi jenkins[27383]: 2022-12-09 10:17:54.285+0000 [id=1]        INFO        org.eclipse.jetty.server.Server#doStart: Started Server@50caa560{STARTING}[10.0.12,sto=0] @8336ms
Dec 09 10:17:54 fat-boi jenkins[27383]: 2022-12-09 10:17:54.295+0000 [id=24]        INFO        winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
Dec 09 10:17:55 fat-boi jenkins[27383]: 2022-12-09 10:17:55.564+0000 [id=31]        INFO        jenkins.InitReactorRunner$1#onAttained: Started initialization
Dec 09 10:17:55 fat-boi jenkins[27383]: 2022-12-09 10:17:55.603+0000 [id=30]        INFO        jenkins.InitReactorRunner$1#onAttained: Listed all plugins
Dec 09 10:17:59 fat-boi jenkins[27383]: 2022-12-09 10:17:59.408+0000 [id=32]        INFO        jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
Dec 09 10:17:59 fat-boi jenkins[27383]: 2022-12-09 10:17:59.441+0000 [id=35]        INFO        jenkins.InitReactorRunner$1#onAttained: Started all plugins
Dec 09 10:17:59 fat-boi jenkins[27383]: 2022-12-09 10:17:59.512+0000 [id=32]        INFO        jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
Dec 09 10:18:00 fat-boi jenkins[27383]: 2022-12-09 10:18:00.798+0000 [id=37]        INFO        jenkins.InitReactorRunner$1#onAttained: System config loaded
Dec 09 10:18:00 fat-boi jenkins[27383]: 2022-12-09 10:18:00.806+0000 [id=29]        INFO        jenkins.InitReactorRunner$1#onAttained: System config adapted
Dec 09 10:18:00 fat-boi jenkins[27383]: 2022-12-09 10:18:00.812+0000 [id=29]        INFO        jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
Dec 09 10:18:00 fat-boi jenkins[27383]: 2022-12-09 10:18:00.821+0000 [id=37]        INFO        jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
Dec 09 10:18:01 fat-boi jenkins[27383]: 2022-12-09 10:18:01.035+0000 [id=51]        INFO        hudson.util.Retrier#start: Attempt #1 to do the action check updates server
Dec 09 10:18:01 fat-boi jenkins[27383]: WARNING: An illegal reflective access operation has occurred
Dec 09 10:18:01 fat-boi jenkins[27383]: WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/var/cache/jenkins/war/WEB-INF/lib/groovy-all-2.4.21.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
Dec 09 10:18:01 fat-boi jenkins[27383]: WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
Dec 09 10:18:01 fat-boi jenkins[27383]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
Dec 09 10:18:01 fat-boi jenkins[27383]: WARNING: All illegal access operations will be denied in a future release
Dec 09 10:18:01 fat-boi jenkins[27383]: 2022-12-09 10:18:01.994+0000 [id=32]        INFO        jenkins.install.SetupWizard#init:
Dec 09 10:18:01 fat-boi jenkins[27383]: *************************************************************
Dec 09 10:18:01 fat-boi jenkins[27383]: *************************************************************
Dec 09 10:18:01 fat-boi jenkins[27383]: *************************************************************
Dec 09 10:18:01 fat-boi jenkins[27383]: Jenkins initial setup is required. An admin user has been created and a password generated.
Dec 09 10:18:01 fat-boi jenkins[27383]: Please use the following password to proceed to installation:
Dec 09 10:18:01 fat-boi jenkins[27383]: hooplah
Dec 09 10:18:01 fat-boi jenkins[27383]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
Dec 09 10:18:01 fat-boi jenkins[27383]: *************************************************************
Dec 09 10:18:01 fat-boi jenkins[27383]: *************************************************************
Dec 09 10:18:01 fat-boi jenkins[27383]: *************************************************************
Dec 09 10:19:15 fat-boi systemd[1]: jenkins.service: start operation timed out. Terminating.
Dec 09 10:19:15 fat-boi jenkins[27383]: 2022-12-09 10:19:15.936+0000 [id=25]        INFO        winstone.Logger#logInternal: JVM is terminating. Shutting down Jetty
Dec 09 10:19:15 fat-boi jenkins[27383]: 2022-12-09 10:19:15.941+0000 [id=25]        INFO        org.eclipse.jetty.server.Server#doStop: Stopped Server@50caa560{STOPPING}[10.0.12,sto=0]
Dec 09 10:19:16 fat-boi systemd[1]: jenkins.service: Failed with result 'timeout'.
Dec 09 10:19:16 fat-boi systemd[1]: Failed to start Jenkins Continuous Integration Server.
Dec 09 10:19:16 fat-boi systemd[1]: jenkins.service: Consumed 4min 37.771s CPU time.
Dec 09 10:19:16 fat-boi systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 3
Dec 09 10:23:50 fat-boi systemd[1]: Starting Jenkins Continuous Integration Server...
Dec 09 10:23:52 fat-boi jenkins[27850]: Running from: /usr/share/java/jenkins.war
...

通过网上查资料,我发现有些 java 版本可能会导致这个错误,但我的好像没问题

openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu222.04)
OpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu222.04, mixed mode

有人遇到过这个问题吗?超时错误让我无计可施。

答案1

Jenkins服务需要一定的时间才能在定义的时间内启动。您可以运行以下命令来检查中的服务TimeoutStartSec配置。JenkinsSystemD

$ sudo systemctl show jenkins | grep ^Timeout
TimeoutStartUSec=1min 30s
TimeoutStopUSec=infinity

您可以在部分下的文件TimeoutStartSec中添加。/lib/systemd/system/jenkins.service[Service]

例如

[Service]
TimeoutStartSec=180

相关内容