启动失败的一些表现:Starting jenkins (via systemctl): Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
[FAILED]
常见的解决方案:
1)修改jdk配置
——————————————————————————
编辑文件:vim /etc/init.d/jenkins
找到 candidates, 在第一行 加入 自己的jdk的java路径
——————————————————————————
2)校验Java版本是否匹配。不匹配的验证方式如下:——————————————————————————————————————————
jenkins -v 输出如下:
Sep 08, 2022 3:43:13 PM executable.Main verifyJavaVersion
SEVERE: Running with Java class version 52, which is older than the Minimum required version 55. See https://jenkins.io/redirect/java-support/
java.lang.UnsupportedClassVersionError: 52.0
at executable.Main.verifyJavaVersion(Main.java:145)
at executable.Main.main(Main.java:109)
Jenkins requires Java versions [17, 11] but you are running with Java 1.8 from /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64/jre
java.lang.UnsupportedClassVersionError: 52.0
at executable.Main.verifyJavaVersion(Main.java:145)
at executable.Main.main(Main.java:109)
——————————————————————————————————————————
3)端口被占用
修改端口:
————————————————————
修改配置文件
vim /etc/sysconfig/jenkins
修改 JENKINS_PORT="7777"
:wq 保存退出
然后重启jenkins
————————————————————
第二种修改端口的方式:
——————————————————————
vim /usr/lib/systemd/system/jenkins.service
Environment="JENKINS_PORT=7777"
:wq 保存退出
重新加载服务:
systemctl daemon-reload
重启Jenkins:
systemctl start jenkins
或
service jenkins start
——————————————————————
如果依然提示端口被占用:
安装openjdk11
——————————————————————————————————
官方文档:https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos