启动sonarqube服务后,从客户端不能访问主机。查询日志文件 /usr/local/sonarqube-5.0.1/logs/sonar.log 后,发现如下错误:
2016.06.20 18:31:25 INFO sea[o.s.p.ProcessEntryPoint] Starting search
2016.06.20 18:31:25 INFO sea[o.s.s.SearchServer] Starting Elasticsearch[sonarqube] on port 9001
2016.06.20 18:31:25 INFO sea[o.elasticsearch.node] [sonar-1466427684530] version[1.1.2], pid[4912], build[e511f7b/2014-05-22T12:27:39Z]
2016.06.20 18:31:25 INFO sea[o.elasticsearch.node] [sonar-1466427684530] initializing ...
2016.06.20 18:31:25 INFO sea[o.e.plugins] [sonar-1466427684530] loaded [], sites []
2016.06.20 18:31:27 INFO sea[o.elasticsearch.node] [sonar-1466427684530] initialized
2016.06.20 18:31:27 INFO sea[o.elasticsearch.node] [sonar-1466427684530] starting ...
2016.06.20 18:31:27 WARN sea[o.s.p.ProcessEntryPoint] Fail to start search
org.elasticsearch.transport.BindTransportException: Failed to bind to [9001]
......
java.net.BindException: Cannot assign requested address
解决问题:
问题的关键在于红字给出的错误。 说明9001端口被别的程序占用了(很可能是上次启动遗留下来的elasticsearch进程占用的)
# lsof -i:9001|more
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 20598 root 184u IPv4 10467575 0t0 TCP *:etlservicemgr (LISTEN)
java 20598 root 186u IPv4 10481815 0t0 TCP svnhost.:34460->svnhost.:etlservicemgr (ESTABLISHED)
java 20598 root 187u IPv4 10481117 0t0 TCP svnhost.:etlservicemgr->svnhost.:34460 (ESTABLISHED)
...
杀掉这个进程即可
# kill -9 20598
然后重新启动SonarQube就好了