对于运维人员来说备份数据是非常重要的,不管理数据库还是配置文件。在每次变更的操作最好做一个文件备份。这里仅记录一下jenkins的配置文件错误导致无法启动服务的问题。
修改配置文件前切记先备份,以防错误导致数据的丢失。
首先找到jenkins的安装目录,如果使用rpm安装的可以这样找到。
rpm -ql jenkins-2.89.4-1.1.noarch
默认rpm安装目录在:/usr/lib/jenkins,而配置文件config.xml就是此目录下;
cp config.xml{,.bak} #备份配置文件
其它的安装目录可根据错误信息找到。
错误信息提示如下:
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)
Caused: 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:167)
Caused: java.io.IOException: Unable to read /var/lib/jenkins/config.xml
at hudson.XmlFile.unmarshal(XmlFile.java:169)
at jenkins.model.Jenkins.loadConfig(Jenkins.java:3067)
at jenkins.model.Jenkins.access$1200(Jenkins.java:304)
at jenkins.model.Jenkins$14.run(Jenkins.java:3085)
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$5.runTask(Jenkins.java:1068)
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: org.jvnet.hudson.reactor.ReactorException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:269)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:47)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1102)
at jenkins.model.Jenkins.<init>(Jenkins.java:904)
at hudson.model.Hudson.<init>(Hudson.java:86)
at hudson.model.Hudson.<init>(Hudson.java:82)
at hudson.WebAppMain$3.run(WebAppMain.java:233)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain$3.run(WebAppMain.java:250)
这里注意红字的部分,提示配置文件中只支持1.0,而不是1.1。然后查看配置文件config.xml发现第一行中果然是1.1,把它改回1.0试下。
sed -i 's/1.1/1.0/' config.xml
重新启动Jenkins服务即可以成功看到界面了。
说明,可能其它的升级版本原因也可能会导致类似的问题,但是最重要的是查看错误日志,提示信息,找解决方法。