# 所选版本
jdk-8u361-linux-x64.rpm
jenkins-2.164.1-1.1.noarch.rpm
rpm -ivh *
在
/etc/rc.d/init.d/jenkins/candidates
中可以看到安装的Jenkins适配什么Java版本,比如能看出来我安装的 Jenkins 适配 Java1.7 和 Java1.8
vim /etc/rc.d/init.d/jenkins
# 找到如下部分,修改 Java 路径,注释掉其他
# 通过命令 which Java 查看 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/bin/java
"
用户默认是
Jenkins
,将JENKINS_USER
的值改成root
,如果不是root
就会启动失败;我一开始用的admin
,在启动环节疯狂报错
vim /etc/sysconfig/jenkins
# 只改 JENKINS_USER
JENKINS_HOME="/var/lib/jenkins"
JENKINS_JAVA_CMD=""
JENKINS_USER="root"
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
JENKINS_PORT="8080"
JENKINS_LISTEN_ADDRESS=""
JENKINS_HTTPS_PORT=""
JENKINS_HTTPS_KEYSTORE=""
JENKINS_HTTPS_KEYSTORE_PASSWORD=""
JENKINS_HTTPS_LISTEN_ADDRESS=""
JENKINS_DEBUG_LEVEL="5"
JENKINS_ENABLE_ACCESS_LOG="no"
JENKINS_HANDLER_MAX="100"
JENKINS_HANDLER_IDLE="20"
JENKINS_ARGS=""
systemctl start jenkins
systemctl stop jenkins
systemctl restart jenkins
All illegal access operations will be denied in a future release
启动后出现Java非法访问,我用的Java11出现,降低版本后错误改变,如有知晓解决,望留言,还请不吝赐教
systemctl stop jenkins.service
rpm -e jenkins
rpm -qa | grep jenkins # 查看是否还有jenkins依赖,有就删除
rm -rf /etc/sysconfig/jenkins.rpmsave
rm -rf /var/cache/jenkins/
rm -rf /var/lib/jenkins/
rm -rf /var/log/jenkins
rm -rf /usr/lib/jenkins
# 查看系统中默认安装的jdk:
rpm -qa|grep jdk
yum -y remove java-11-openjdk*
# 启动报错
[root@test ~]# systemctl start jenkins
Job for jenkins.service failed because the control process exited with error code.
See "systemctl status jenkins.service" and "journalctl -xe" for details.
# 查看具体报错内容
[root@test ~]# systemctl status jenkins.service
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; generated)
Active: failed (Result: exit-code) since Fri 2023-02-24 00:32:56 CST; 37s ago
Docs: man:systemd-sysv-generator(8)
Process: 1926718 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
Main PID: 1921125 (code=exited, status=1/FAILURE)
Feb 24 00:32:56 test systemd[1]: Starting LSB: Jenkins Automation Server...
Feb 24 00:32:56 test jenkins[1926718]: Starting Jenkins runuser: user admin does not exist
Feb 24 00:32:56 test jenkins[1926718]: [FAILED]
Feb 24 00:32:56 test systemd[1]: jenkins.service: Control process exited, code=exited stat>
Feb 24 00:32:56 test systemd[1]: jenkins.service: Failed with result 'exit-code'.
Feb 24 00:32:56 test systemd[1]: Failed to start LSB: Jenkins Automation Server.
lines 1-13/13 (END)...skipping...
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; generated)
Active: failed (Result: exit-code) since Fri 2023-02-24 00:32:56 CST; 37s ago
Docs: man:systemd-sysv-generator(8)
Process: 1926718 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
Main PID: 1921125 (code=exited, status=1/FAILURE)
Feb 24 00:32:56 test systemd[1]: Starting LSB: Jenkins Automation Server...
Feb 24 00:32:56 test jenkins[1926718]: Starting Jenkins runuser: user admin does not exist
Feb 24 00:32:56 test jenkins[1926718]: [FAILED]
Feb 24 00:32:56 test systemd[1]: jenkins.service: Control process exited, code=exited status=1
Feb 24 00:32:56 test systemd[1]: jenkins.service: Failed with result 'exit-code'.
Feb 24 00:32:56 test systemd[1]: Failed to start LSB: Jenkins Automation Server.
将用户名改成 root
解决
# 成功启动
[root@test ~]# systemctl status jenkins.service
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; generated)
Active: active (exited) since Fri 2023-02-24 09:45:20 CST; 24s ago
Docs: man:systemd-sysv-generator(8)
Process: 2006574 ExecStop=/etc/rc.d/init.d/jenkins stop (code=exited, status=0/SUCCESS)
Process: 2006588 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
Main PID: 1921125 (code=exited, status=1/FAILURE)
Feb 24 09:45:20 test systemd[1]: jenkins.service: Succeeded.
Feb 24 09:45:20 test systemd[1]: Stopped LSB: Jenkins Automation Server.
Feb 24 09:45:20 test systemd[1]: Starting LSB: Jenkins Automation Server...
Feb 24 09:45:20 test runuser[2006595]: pam_unix(runuser:session): session opened for user root by (uid=0)
Feb 24 09:45:20 test runuser[2006595]: pam_unix(runuser:session): session closed for user root
Feb 24 09:45:20 test jenkins[2006588]: Starting Jenkins [ OK ]
Feb 24 09:45:20 test systemd[1]: Started LSB: Jenkins Automation Server.
可以说这是我遇见的最后一个坑了,您猜怎么着,在腾讯云防火墙加一下8080的规则就好了;以后一定记得维护安全组的端口
经过很久的折腾,我在想一个问题,如果一开始我用 root
当用户名,即使用的 Java11
以及最新版 Jenkins
,启动时出现 Java
的非法访问警告,是否也能正常启动 Jenkins
?可惜我没有机器再让我尝试了,将这个疑问留存,下次我去尝试一下。有读者知道问题所在,还请您不吝赐教。
2023年2月24日 19:09:57
2.164版本 UI
有点简陋,并且安装插件总是弹出警告的字眼,略微烦躁,索性删了改用 JDK17
& jenkins-2.361.1
,安装方式和配置操作不变,很流畅,先停了服务,再用上面的命令卸载 JDK
和Jenkins
jdk-8u361-linux-x64.rpm
jenkins-2.164.1-1.1.noarch.rpm
jdk-17_linux-x64_bin.rpm
jenkins-2.361.1-1.1.noarch.rpm
升级到了 jenkins-2.375.3-1.1