centos7使用rpm方式安装jenkins启动报错Failed to start LSB: Jenkins Automation Server

参考:https://blog.csdn.net/hello_world_qwp/article/details/82705626

下载网址:https://jenkins.io/zh/download/

centos7使用rpm方式安装jenkins启动报错Failed to start LSB: Jenkins Automation Server_第1张图片

下载rpm包

centos7使用rpm方式安装jenkins启动报错Failed to start LSB: Jenkins Automation Server_第2张图片

运行rpm安装命令

rpm -ivh ./jenkins-2.204.2-1.1.noarch.rpm

启动服务报错,查看状态

# 设置开机启动
systemctl enable jenkins.service
# 启动jenkins
systemctl start jenkins.service
# 查看状态
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 Fri 2020-02-21 15:24:15 CST; 14s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 20173 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)

Feb 21 15:24:15 cdhnode1.dongriaf.com systemd[1]: Starting LSB: Jenkins Automation Server...
Feb 21 15:24:15 cdhnode1.dongriaf.com runuser[20178]: pam_unix(runuser:session): session o...0)
Feb 21 15:24:15 cdhnode1.dongriaf.com jenkins[20173]: Starting Jenkins bash: /usr/bin/java...ry
Feb 21 15:24:15 cdhnode1.dongriaf.com runuser[20178]: pam_unix(runuser:session): session c...ns
Feb 21 15:24:15 cdhnode1.dongriaf.com jenkins[20173]: [FAILED]
Feb 21 15:24:15 cdhnode1.dongriaf.com systemd[1]: jenkins.service: control process exited,...=1
Feb 21 15:24:15 cdhnode1.dongriaf.com systemd[1]: Failed to start LSB: Jenkins Automation ...r.
Feb 21 15:24:15 cdhnode1.dongriaf.com systemd[1]: Unit jenkins.service entered failed state.
Feb 21 15:24:15 cdhnode1.dongriaf.com systemd[1]: jenkins.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

Failed to start LSB: Jenkins Automation Server

刚开始怀疑是jenkins的8080端口被占用

修改jenkins的配置文件:

vim /etc/sysconfig/jenkins

端口改成其他

JENKINS_PORT="9090"

结果还是不行

后面网上找资料是 Jenkins 未加载到 java 环境的问题,直接到修改 Jenkins 的启动文件

vim /etc/init.d/jenkins

编辑再candidates加上jdk的路径

/usr/local/jdk1.8.0_231/bin/java
/usr/local/jdk1.8.0_231/jre/bin/java

candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/lib/jvm/java-11.0/bin/java
/usr/lib/jvm/jre-11.0/bin/java
/usr/lib/jvm/java-11-openjdk-amd64
/usr/bin/java
/usr/local/jdk1.8.0_231/bin/java
/usr/local/jdk1.8.0_231/jre/bin/java
"

再次尝试启动成功

systemctl start jenkins

查看运行日志

tail -n 300 -f /var/log/jenkins/jenkins.log

rpm安装后jenkins的目录为

/var/lib/jenkins/

 

你可能感兴趣的:(jenkins)