升级jenkins之后无法启动 报错Unable to read /var/lib/jenkins/config.xml
故障记录
点击jenkins升级后再点击回滚到之前版本,jenkins就起不来了。
欲哭无泪,报错如下
hudson.util.HudsonFailedToLoad: org.jvnet.hudson.reactor.ReactorException: java.io.IOException: Unable to read /var/lib/jenkins/config.xml at hudson.WebAppMain$3.run(WebAppMain.java:248) Caused by: org.jvnet.hudson.reactor.ReactorException: java.io.IOException: Unable to read /var/lib/jenkins/config.xml at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:269) at jenkins.InitReactorRunner.run(InitReactorRunner.java:47) at jenkins.model.Jenkins.executeReactor(Jenkins.java:1075) at jenkins.model.Jenkins.<init>(Jenkins.java:915) at hudson.model.Hudson.<init>(Hudson.java:85) at hudson.model.Hudson.<init>(Hudson.java:81) at hudson.WebAppMain$3.run(WebAppMain.java:231) Caused by: java.io.IOException: Unable to read /var/lib/jenkins/config.xml at hudson.XmlFile.unmarshal(XmlFile.java:160) at jenkins.model.Jenkins.loadConfig(Jenkins.java:2977) at jenkins.model.Jenkins.access$1100(Jenkins.java:325) at jenkins.model.Jenkins$16.run(Jenkins.java:2995) at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169) at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282) at jenkins.model.Jenkins$7.runTask(Jenkins.java:1051) at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210) at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: com.thoughtworks.xstream.io.StreamException: : only 1.0 is supported as <?xml version not '1.1' (position: START_DOCUMENT seen <?xml version=\'1.1\'... @1:19) at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:124) at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148) at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:141) at com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:118) at com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:103) at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:63) at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:54) at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:65) at hudson.XmlFile.unmarshal(XmlFile.java:158) ... 11 more Caused by: org.xmlpull.v1.XmlPullParserException: only 1.0 is supported as <?xml version not '1.1' (position: START_DOCUMENT seen <?xml version=\'1.1\'... @1:19) at org.xmlpull.mxp1.MXParser.parseXmlDeclWithVersion(MXParser.java:2608) at org.xmlpull.mxp1.MXParser.parseXmlDecl(MXParser.java:2592) at org.xmlpull.mxp1.MXParser.parsePI(MXParser.java:2466) at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1447) at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395) at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093) at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:109) ... 19 more
幸好之前用ThinBackup插件做了每日备份。
问题原因:升级jenkins之后配置文件格式变化,导致降配后的jenkins无法读取配置文件
解决方法:
1,cd /var/lib/jenkins/ #进入到jenkins的程序目录
mv config.xml config.xmlbak #重命名
2,cd /backupjenkins #切换到ThinBackup的备份目录
cd FULL-2018-02-05_00-00 #切换到每日备份目录
cp config.xml /var/lib/jenkins/ #还原配置文件
3,service jenkins restart #重启jenkins
4,大功告成,jenkins又可以恢复使用啦~跑了几个构建也ok。
教训:
不要随意升级jenkins,升级操作请谨慎,升级之前请对程序目录进行备份;养成备份的好习惯,别等到宕机才欲哭无泪
ps:其实重命名config.xml后重启jenkins已经可以重启成功了,但是相关的用户配置和安全策略都没有了,jenkins处于没有保护的状态,所以最好是使用之前的配置文件进行还原。
写文不易,转载请注明出处