Jenkins安装过程中的一些问题及解决

时间:2024-03-16 12:17:07

在docker容器中安装的—docker机器(有固定ip)

1、安装步骤参考这里:https://www.jianshu.com/p/c517f09df025

2、安装过程中遇到的问题
(1) 问题1 无法启动?
[[email protected] /home] $sudo service jenkins start
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]

【解决】
[[email protected] /home] $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 Sat 2020-06-27 18:38:53 CST; 15s ago
Docs: man:systemd-sysv-generator(8)
Process: 178319 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)

[[email protected] /home] $journalctl -xe
Failed to check if we are in the ‘systemd-journal’ group: No such process
No journal files were opened due to insufficient permissions.
经查百度:需要把当前docker容器中的java路径放到/etc/init.d/jenkins文件中
[[email protected] /home] $whereis java
java: /opt/xxxxx/install/ajdk-8.4.7-b187/bin/java
[[email protected] /home] $sudo vim /etc/init.d/jenkins
如下图,增加一行接口
Jenkins安装过程中的一些问题及解决
[[email protected] /home] $sudo service jenkins start
Starting jenkins (via systemctl): Warning: jenkins.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
[ OK ]

再次check状态
[[email protected] /home] $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 Sat 2020-06-27 18:42:24 CST; 7min ago
Docs: man:systemd-sysv-generator(8)
Process: 181038 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/jenkins.service
└─181121 /opt/taobao/install/ajdk-8.4.7-b187/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --lo…
Warning: jenkins.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
[[email protected] /home] $sudo systemctl daemon-reload
看看jenkins的日志
[[email protected] /home] $ps -ef | grep jenkins
root 181121 1 4 18:46 ? 00:00:09 /opt/taobao/install/ajdk-8.4.7-b187/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=9527 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
admin 187336 161634 0 18:54 pts/0 00:00:00 grep --color=auto jenkins
[[email protected] /home] $sudo tailf /var/log/jenkins/jenkins.log
Running from: /usr/lib/jenkins/jenkins.war
2020-06-27 10:55:50.424+0000 [id=1] WARNING winstone.Logger#logInternal: Parameter handlerCountMax is now deprecated
2020-06-27 10:55:50.459+0000 [id=1] WARNING winstone.Logger#logInternal: Parameter handlerCountMaxIdle is now deprecated
2020-06-27 10:55:50.469+0000 [id=1] INFO org.eclipse.jetty.util.log.Log#initialized: Logging initialized @980ms to org.eclipse.jetty.util.log.JavaUtilLog
2020-06-27 10:55:50.583+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file
2020-06-27 10:55:50.637+0000 [id=1] WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2020-06-27 10:55:50.728+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-9.4.27.v20200227; built: 2020-02-27T18:37:21.340Z; git: a304fd9f351f337e7c0e2a7c28878dd536149c6c; jvm 1.8.0_152-b187
2020-06-27 10:55:51.236+0000 [id=1] INFO o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2020-06-27 10:55:51.886+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2020-06-27 10:55:51.886+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2020-06-27 10:55:51.890+0000 [id=1] INFO o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 600000ms
2020-06-27 10:55:52.477+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins home directory: /var/lib/jenkins found at: SystemProperties.getProperty(“JENKINS_HOME”)
2020-06-27 10:55:52.542+0000 [id=1] SEVERE hudson.util.BootFailure#publish: Failed to initialize Jenkins
java.lang.NullPointerException
at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)
at sun.awt.FontConfiguration.init(FontConfiguration.java:107)
at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774)
at sun.font.SunFontManager$2.run(SunFontManager.java:431)
at java.security.AccessController.doPrivileged(Native Method)
at sun.font.SunFontManager.(SunFontManager.java:376)
at sun.awt.FcFontManager.(FcFontManager.java:35)
at sun.awt.X11FontManager.(X11FontManager.java:57)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83)
at java.security.AccessController.doPrivileged(Native Method)
at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.awt.Font.getFont2D(Font.java:495)
at java.awt.Font.getFamily(Font.java:1240)
at java.awt.Font.getFamily_NoClientCode(Font.java:1214)
at java.awt.Font.getFamily(Font.java:1206)
at java.awt.Font.toString(Font.java:1703)
at hudson.util.ChartUtil.(ChartUtil.java:260)
at hudson.WebAppMain.contextInitialized(WebAppMain.java:218)
Caused: hudson.util.AWTProblem
at hudson.WebAppMain.contextInitialized(WebAppMain.java:219)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:933)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:553)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:892)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:356)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1445)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1409)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:825)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:275)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
at org.eclipse.jetty.server.Server.start(Server.java:407)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
at org.eclipse.jetty.server.Server.doStart(Server.java:371)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
at winstone.Launcher.(Launcher.java:182)
at winstone.Launcher.main(Launcher.java:355)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at Main._main(Main.java:375)
at Main.main(Main.java:151)
2020-06-27 10:55:53.171+0000 [id=1] INFO o.e.j.s.handler.ContextHandler#doStart: Started [email protected]{Jenkins v2.235.1,/,file:///var/cache/jenkins/war/,AVAILABLE}{/var/cache/jenkins/war}
2020-06-27 10:55:53.200+0000 [id=1] INFO o.e.j.server.AbstractConnector#doStart: Started [email protected]{HTTP/1.1, (http/1.1)}{0.0.0.0:9527}
2020-06-27 10:55:53.201+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: Started @3712ms
2020-06-27 10:55:53.202+0000 [id=21] INFO winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
经查百度:Caused: hudson.util.AWTProblem的解决:参考这里

从上面截取重点部分即解决方案
The problem can be mitigated by installing the full jdk. e.g.: yum -y install java-1.8.0-openjdk-devel or installing the current https://jdk8.java.net. However, the Jenkins 1.548 is using an older XStream library, which is not compatible with Java 8. If you get the following exception: http://jira.codehaus.org/browse/XSTR-746 you will have to move “back” to JDK 1.7.

[[email protected] /home] $$sudo yum -y install java-1.8.0-openjdk-devel

安装完成后,重新启动jenkins,同时监控日志(日志已经不报错了)
[[email protected] /home] $sudo service jenkins restart
Restarting jenkins (via systemctl): [ OK ]
日志监控—略

其他略。