Jenkins启动失败:Failed to start LSB: Jenkins Automation Server.

启动systemctl start jenkins.service提示

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

查看状态systemctl status jenkins.service报错:

● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: failed (Result: exit-code) since 五 2022-12-02 09:39:17 CST; 15s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 19409 ExecStop=/etc/rc.d/init.d/jenkins stop (code=exited, status=0/SUCCESS)
  Process: 19421 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)

12月 02 09:39:17 jenkins systemd[1]: Starting LSB: Jenkins Automation Server...
12月 02 09:39:17 jenkins runuser[19426]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
12月 02 09:39:17 jenkins jenkins[19421]: Starting Jenkins bash: /usr/local/java/bin/java: No such file or directory
12月 02 09:39:17 jenkins runuser[19426]: pam_unix(runuser:session): session closed for user jenkins
12月 02 09:39:17 jenkins jenkins[19421]: [FAILED]
12月 02 09:39:17 jenkins systemd[1]: jenkins.service: control process exited, code=exited status=1
12月 02 09:39:17 jenkins systemd[1]: Failed to start LSB: Jenkins Automation Server.
12月 02 09:39:17 jenkins systemd[1]: Unit jenkins.service entered failed state.
12月 02 09:39:17 jenkins systemd[1]: jenkins.service failed.

原因是我的java环境重新安装后,新的java地址没有配置到jenkins中
使用 which java 查看java安装地址

[root@jenkins /opt]#which java
/usr/local/java-1.8/jdk1.8.0_351/bin/java

将打印出的地址复制

vi /etc/rc.d/init.d/jenkins

复制到此处

candidates="
/etc/alternatives/java
/usr/bin/java
/usr/local/java/bin/java
/usr/local/java-1.8/jdk1.8.0_351/bin/java
"

:wq保存
执行systemctl daemon-reload 读取配置
然后重启jenkins systemctl restart jenkins.service
完成!!

你可能感兴趣的:(那些让你措手不及的错误和异常,兼职运维的时光,CI/CD,jenkins,运维,java)