yum install java-11-openjdk* -y
[[email protected] ~]# java -version openjdk version "11.0.15" 2022-04-19 LTS OpenJDK Runtime Environment 18.9 (build 11.0.15+9-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+9-LTS, mixed mode, sharing)
[[email protected] ~]# java -version openjdk version "1.8.0_332" OpenJDK Runtime Environment (build 1.8.0_332-b09) OpenJDK 64-Bit Server VM (build 25.332-b09, mixed mode) [[email protected] ~]# alternatives --config java 共有 2 个提供“java”的程序。 选项 命令 ----------------------------------------------- 1 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.15.0.9-2.el7_9.x86_64/bin/java) *+ 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64/jre/bin/java) 按 Enter 保留当前选项[+],或者键入选项编号:1 [[email protected] ~]# java -version openjdk version "11.0.15" 2022-04-19 LTS OpenJDK Runtime Environment 18.9 (build 11.0.15+9-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+9-LTS, mixed mode, sharing)
yum install jenkins -y
systemctl start jenkins
[[email protected] ~]# systemctl status jenkins ● jenkins.service - Jenkins Continuous Integration Server Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled) Active: active (running) since 四 2022-07-21 11:11:11 CST; 1min 26s ago Main PID: 1744 (java) CGroup: /system.slice/jenkins.service └─1744 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=%C/jenkins/war --httpPort=8080 如果有报错的话,需要使用 journalctl -xe 命令看下日志信息,这里演示下如果使用的jdk1.8而非jdk11的情况, jenkins-2.360-1.1 版本需要使用jdk11里的运行时环境 alternatives --config java 共有 2 个提供“java”的程序。 选项 命令 ----------------------------------------------- + 1 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.15.0.9-2.el7_9.x86_64/bin/java) * 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64/jre/bin/java) 按 Enter 保留当前选项[+],或者键入选项编号:2 [[email protected] secrets]# systemctl start jenkins Job for jenkins.service failed. See "systemctl status jenkins.service" and "journalctl -xe" for details. [[email protected] secrets]# journalctl -xe -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit jenkins.service has failed. -- -- The result is failed. bogon systemd[1]: Unit jenkins.service entered failed state. bogon systemd[1]: jenkins.service failed. bogon systemd[1]: jenkins.service holdoff time over, scheduling restart. bogon systemd[1]: Stopped Jenkins Continuous Integration Server. -- Subject: Unit jenkins.service has finished shutting down -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit jenkins.service has finished shutting down. bogon systemd[1]: Starting Jenkins Continuous Integration Server... -- Subject: Unit jenkins.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit jenkins.service has begun starting up. .... bogon jenkins[2448]: 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.332.b09-1.el7_9.x86_64/jre ... -- Subject: Unit jenkins.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit jenkins.service has failed. -- -- The result is failed.
其中 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.332.b09-1.el7_9.x86_64/jre 的意思就是 jre的版本太低,需要使用jdk11的jre.