You will need to explicitly install a Java runtime environment, because Oracle’s Java RPMs are incorrect and fail to register as providing a java dependency. Thus, adding an explicit dependency requirement on Java would force installation of the OpenJDK JVM.
service jenkins start service jenkins stop service jenkins restart
启动失败日志:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[root@iZuefw6wnv6uycZ ~]# 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 Tue 2024-12-10 13:35:05 CST; 12s ago Docs: man:systemd-sysv-generator(8) Process: 15057 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
Dec 10 13:35:05 iZuefw6wnv6uycZ systemd[1]: Starting LSB: Jenkins Automation Server... Dec 10 13:35:05 iZuefw6wnv6uycZ runuser[15062]: pam_unix(runuser:session): session opened for user jenkins by (uid=0) Dec 10 13:35:05 iZuefw6wnv6uycZ jenkins[15057]: Starting Jenkins bash: /usr/bin/java: No such file or directory Dec 10 13:35:05 iZuefw6wnv6uycZ runuser[15062]: pam_unix(runuser:session): session closed for user jenkins Dec 10 13:35:05 iZuefw6wnv6uycZ jenkins[15057]: [FAILED] Dec 10 13:35:05 iZuefw6wnv6uycZ systemd[1]: jenkins.service: control process exited, code=exited status=1 Dec 10 13:35:05 iZuefw6wnv6uycZ systemd[1]: Failed to start LSB: Jenkins Automation Server. Dec 10 13:35:05 iZuefw6wnv6uycZ systemd[1]: Unit jenkins.service entered failed state. Dec 10 13:35:05 iZuefw6wnv6uycZ systemd[1]: jenkins.service failed.
可以查看到这里面Starting Jenkins bash: /usr/bin/java: No such file or directory 表示在/usr/bin/java 找到不到java环境,但我是配置了的。所以这里需要配置到对应路径的软连接
[root@iZuefw6wnv6uycZ ~]# service jenkins start Starting jenkins (via systemctl): [ OK ] [root@iZuefw6wnv6uycZ ~]# systemctl status jenkins.service ● jenkins.service - LSB: Jenkins Automation Server Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled) Active: active (running) since Tue 2024-12-10 13:39:59 CST; 6s ago Docs: man:systemd-sysv-generator(8) Process: 15095 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS) CGroup: /system.slice/jenkins.service └─15114 /usr/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins....
Dec 10 13:39:58 iZuefw6wnv6uycZ systemd[1]: Starting LSB: Jenkins Automation Server... Dec 10 13:39:58 iZuefw6wnv6uycZ runuser[15100]: pam_unix(runuser:session): session opened for user jenkins by (uid=0) Dec 10 13:39:59 iZuefw6wnv6uycZ runuser[15100]: pam_unix(runuser:session): session closed for user jenkins Dec 10 13:39:59 iZuefw6wnv6uycZ systemd[1]: Started LSB: Jenkins Automation Server. Dec 10 13:39:59 iZuefw6wnv6uycZ jenkins[15095]: Starting Jenkins [ OK ]