1:安装好jenkins后,启动失败
启动命令:
systemctl start jenkins
2:报错提示
Job for jenkins.service failed because the control process exited with error code. See “systemctl status jenkins.service” and “journalctl -xe” for details
3:用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 一 2020-11-09 15:31:31 CST; 25min ago
Docs: man:systemd-sysv-generator(8)
Process: 1969 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
11月 09 15:31:31 bogon systemd[1]: Starting LSB: Jenkins Automation Server…
11月 09 15:31:31 bogon runuser[1974]: pam_unix(runuser:session): session opened for user jen…=0)
11月 09 15:31:31 bogon jenkins[1969]: Starting Jenkins bash: /usr/bin/java: 没有那个文件或目录
11月 09 15:31:31 bogon jenkins[1969]: [失败]
11月 09 15:31:31 bogon systemd[1]: jenkins.service: control process exited, code=exited status=1
11月 09 15:31:31 bogon systemd[1]: Failed to start LSB: Jenkins Automation Server.
11月 09 15:31:31 bogon systemd[1]: Unit jenkins.service entered failed state.
11月 09 15:31:31 bogon systemd[1]: jenkins.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
4:原因
从 usr/bin/java: 没有那个文件或目录 可以看出 java 路径不对
5:解决方案
首先确定自己的java版本
java -version
注意: 需要1.8以上的java版本, 如果过低需要重新安装个高版本的
修改jenkins的配置文件
vi /etc/init.d/jenkins
修改图中的地址(原来是/usr/bin/java)
修改完jenkins的配置文件之后好像还需要执行systemctl daemon-reload命令