【问题标题】:SonarQube 7.2 won't start with systemd on CentOS 7SonarQube 7.2 不会在 CentOS 7 上以 systemd 启动
【发布时间】:2019-01-11 09:25:33
【问题描述】:

我在 VM 上安装了 CentOS7,并尝试正确安装 SonarQube 7.2.1。所以我关注this tutorial 并安装 PostgreSQL 而不是 MariaDB。我按照他们的说法编辑了 sonar.properties,并正确安装了 Java 8。

当我想从 sudo systemctl start sonar 开始时,我遇到了一个错误,所以我这样做了 journalctl -xesystemctl status sonar.service

第一个还我

L'unité (unit) sonar.service a commencé à démarrer.
août 03 14:20:44 localhost.localdomain bash[19570]: /bin/bash: /home/enovia/sonarqube-7.2.1/bin/linux-x86-64/sonar.sh: Aucun fichier ou dossier de ce type
août 03 14:20:44 localhost.localdomain systemd[1]: sonar.service: control process exited, code=exited status=127
août 03 14:20:44 localhost.localdomain systemd[1]: Failed to start SonarQube Service.
-- Subject: L'unité (unit) sonar.service a échoué
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

第二个

sonar.service - SonarQube Service
   Loaded: loaded (/etc/systemd/system/sonar.service; enabled; vendor preset: disabled)

  Active: activating (auto-restart) (Result: exit-code) since ven. 2018-08-03 14:41:14 CEST; 3s ago

 Process: 21093 ExecStart=/bin/bash /home/enovia/sonarqube-7.2.1/bin/linux-x86-64/sonar.sh start (code=exited, status=127)


août 03 14:41:14 localhost.localdomain systemd[1]: sonar.service: control process exited, code=exited status=127

août 03 14:41:14 localhost.localdomain systemd[1]: Failed to start SonarQube Service.

août 03 14:41:14 localhost.localdomain systemd[1]: Unit sonar.service entered failed state.

août 03 14:41:14 localhost.localdomain systemd[1]: sonar.service failed.

这是我的 sonar.properties :

sonar.jdbc.username=sonar

sonar.jdbc.password=DatabasePass

sonar.jdbc.url=jdbc:postgresql://localhost/sonar

sonar.web.port=10900

声纳日志文件:

`

--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2018.07.30 15:50:44 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /home/enovia/Bureau/sonarqube-7.2.1/temp
2018.07.30 15:50:44 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2018.07.30 15:50:45 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/home/enovia/Bureau/sonarqube-7.2.1/elasticsearch]: /home/enovia/Bureau/sonarqube-7.2.1/elasticsearch/bin/elasticsearch -Epath.conf=/home/enovia/Bureau/sonarqube-7.2.1/temp/conf/es
2018.07.30 15:50:45 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
2018.07.30 15:50:58 INFO  app[][o.e.p.PluginsService] no modules loaded
2018.07.30 15:50:58 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2018.07.30 15:52:30 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2018.07.30 15:52:32 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [/home/enovia/Bureau/sonarqube-7.2.1]: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/home/enovia/Bureau/sonarqube-7.2.1/temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*:/home/enovia/Bureau/sonarqube-7.2.1/lib/jdbc/mysql/mysql-connector-java-5.1.46.jar org.sonar.server.app.WebServer /home/enovia/Bureau/sonarqube-7.2.1/temp/sq-process8191574965959719695properties
2018.07.30 15:53:36 INFO  app[][o.s.a.SchedulerImpl] Process [web] is stopped
2018.07.30 15:53:38 INFO  app[][o.s.a.SchedulerImpl] Process [es] is stopped
2018.07.30 15:53:38 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
2018.07.30 15:53:38 WARN  app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 143
<-- Wrapper Stopped
--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2018.07.31 12:05:33 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /home/enovia/Bureau/sonarqube-7.2.1/temp
2018.07.31 12:05:33 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2018.07.31 12:05:34 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/home/enovia/Bureau/sonarqube-7.2.1/elasticsearch]: /home/enovia/Bureau/sonarqube-7.2.1/elasticsearch/bin/elasticsearch -Epath.conf=/home/enovia/Bureau/sonarqube-7.2.1/temp/conf/es
2018.07.31 12:05:34 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
Startup failed: Timed out waiting for signal from JVM.
JVM did not exit on request, terminated
JVM exited on its own while waiting to kill the application.
JVM exited in response to signal SIGKILL (9).
JVM Restarts disabled.  Shutting down.
<-- Wrapper Stopped
--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2018.07.31 12:15:56 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /home/enovia/Bureau/sonarqube-7.2.1/temp
2018.07.31 12:15:56 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2018.07.31 12:15:57 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/home/enovia/Bureau/sonarqube-7.2.1/elasticsearch]: /home/enovia/Bureau/sonarqube-7.2.1/elasticsearch/bin/elasticsearch -Epath.conf=/home/enovia/Bureau/sonarqube-7.2.1/temp/conf/es
2018.07.31 12:15:57 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2018.07.31 12:15:58 INFO  app[][o.e.p.PluginsService] no modules loaded
2018.07.31 12:15:58 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2018.07.31 12:16:08 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2018.07.31 12:16:08 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [/home/enovia/Bureau/sonarqube-7.2.1]: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/home/enovia/Bureau/sonarqube-7.2.1/temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*:/home/enovia/Bureau/sonarqube-7.2.1/lib/jdbc/mysql/mysql-connector-java-5.1.46.jar org.sonar.server.app.WebServer /home/enovia/Bureau/sonarqube-7.2.1/temp/sq-process4251581204595748290properties
2018.07.31 12:16:25 INFO  app[][o.s.a.SchedulerImpl] Process [web] is stopped
2018.07.31 12:16:25 INFO  app[][o.s.a.SchedulerImpl] Process [es] is stopped
2018.07.31 12:16:25 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
2018.07.31 12:16:25 WARN  app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 143
<-- Wrapper Stopped
--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2018.08.01 13:41:07 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /home/enovia/sonarqube-7.2.1/temp
2018.08.01 13:41:07 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2018.08.01 13:41:07 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/home/enovia/sonarqube-7.2.1/elasticsearch]: /home/enovia/sonarqube-7.2.1/elasticsearch/bin/elasticsearch -Epath.conf=/home/enovia/sonarqube-7.2.1/temp/conf/es
2018.08.01 13:41:07 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2018.08.01 13:41:09 INFO  app[][o.e.p.PluginsService] no modules loaded
2018.08.01 13:41:09 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2018.08.01 13:41:10 WARN  app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 1
2018.08.01 13:41:10 INFO  app[][o.s.a.SchedulerImpl] Process [es] is stopped
2018.08.01 13:41:10 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped
--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2018.08.01 15:17:17 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /home/enovia/sonarqube-7.2.1/temp
2018.08.01 15:17:17 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2018.08.01 15:17:18 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/home/enovia/sonarqube-7.2.1/elasticsearch]: /home/enovia/sonarqube-7.2.1/elasticsearch/bin/elasticsearch -Epath.conf=/home/enovia/sonarqube-7.2.1/temp/conf/es
2018.08.01 15:17:18 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2018.08.01 15:17:18 INFO  app[][o.e.p.PluginsService] no modules loaded
2018.08.01 15:17:18 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2018.08.01 15:17:20 WARN  app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 1
2018.08.01 15:17:20 INFO  app[][o.s.a.SchedulerImpl] Process [es] is stopped
2018.08.01 15:17:20 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped
--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2018.08.01 15:18:01 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /home/enovia/sonarqube-7.2.1/temp

WrapperSimpleApp: Encountered an error running main: java.nio.file.AccessDeniedException: /home/enovia/sonarqube-7.2.1/temp/conf/es/elasticsearch.yml
java.nio.file.AccessDeniedException: /home/enovia/sonarqube-7.2.1/temp/conf/es/elasticsearch.yml
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:244)
    at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
    at java.nio.file.Files.delete(Files.java:1126)
    at org.sonar.process.FileUtils2$DeleteRecursivelyFileVisitor.visitFile(FileUtils2.java:170)
    at org.sonar.process.FileUtils2$DeleteRecursivelyFileVisitor.visitFile(FileUtils2.java:165)
    at java.nio.file.Files.walkFileTree(Files.java:2670)
    at java.nio.file.Files.walkFileTree(Files.java:2742)
    at org.sonar.process.FileUtils2.deleteDirectoryImpl(FileUtils2.java:127)
    at org.sonar.process.FileUtils2.deleteDirectory(FileUtils2.java:112)
    at org.sonar.application.AppFileSystem$CleanTempDirFileVisitor.visitFile(AppFileSystem.java:117)
    at org.sonar.application.AppFileSystem$CleanTempDirFileVisitor.visitFile(AppFileSystem.java:101)
    at java.nio.file.Files.walkFileTree(Files.java:2670)
    at org.sonar.application.AppFileSystem.createOrCleanTempDirectory(AppFileSystem.java:96)
    at org.sonar.application.AppFileSystem.reset(AppFileSystem.java:62)
    at org.sonar.application.App.start(App.java:55)
    at org.sonar.application.App.main(App.java:78)
    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 org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
    at java.lang.Thread.run(Thread.java:748)
<-- Wrapper Stopped
--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2018.08.01 15:38:18 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /etc/sonarqube-7.2.1/temp
2018.08.01 15:38:18 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2018.08.01 15:38:18 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/etc/sonarqube-7.2.1/elasticsearch]: /etc/sonarqube-7.2.1/elasticsearch/bin/elasticsearch -Epath.conf=/etc/sonarqube-7.2.1/temp/conf/es
2018.08.01 15:38:18 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2018.08.01 15:38:19 INFO  app[][o.e.p.PluginsService] no modules loaded
2018.08.01 15:38:19 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2018.08.01 15:38:29 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2018.08.01 15:38:29 INFO  app[][o.s.a.p.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [/etc/sonarqube-7.2.1]: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/etc/sonarqube-7.2.1/temp -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -cp ./lib/common/*:/etc/sonarqube-7.2.1/lib/jdbc/mysql/mysql-connector-java-5.1.46.jar org.sonar.server.app.WebServer /etc/sonarqube-7.2.1/temp/sq-process1389488387217549973properties
2018.08.01 15:38:46 INFO  app[][o.s.a.SchedulerImpl] Process [web] is stopped
2018.08.01 15:38:46 INFO  app[][o.s.a.SchedulerImpl] Process [es] is stopped
2018.08.01 15:38:46 WARN  app[][o.s.a.p.AbstractProcessMonitor] Process exited with exit value [es]: 143
2018.08.01 15:38:46 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped

【问题讨论】:

  • SonarQube 日志文件的内容是什么?请记住,您不能以root 的身份运行。
  • @JeroenHeier 我使用我创建的仅使用 SonarQube 的声纳用户运行它。 Sonar 用户拥有对所有 SonarQube 目录的权限,并且不是 root 用户。我将 sonar.log 文件添加到问题中
  • es.log 说什么?根据日志,elasticSearch 进程失败(您确定它不是以 root 身份启动的吗?)
  • 我昨天清理了我的日志文件。由于即使我尝试使用“systemctl start sonar”命令运行声纳,也没有创建日志文件。它会产生与以前相同的消息。我不使用 root 用户运行此命令,但 CentOS 要求我的用户密码来启动该命令。我的用户在声纳和车轮组中

标签: linux centos sonarqube centos7 systemd


【解决方案1】:

更新 sonar.sh 文件中的 RUN_AS_USER 属性并重新启动 SonarQube。

并且还要确保 SonarQube 目录中没有权限相关的问题,以更安全地运行 chown user:user -R /home/SonarQube_home

【讨论】:

  • 我已经更新了 sonar.sh 文件并运行了 chown 但没有效果 :( 仍然没有日志 ...
  • 你能分享你的/etc/systemd/system/sonar.service文件吗
【解决方案2】:

我最近在 Centos 7.6 和 SonarQube 7.6 上遇到了这个 sonarqube restarting issue,这花费了我的 CICD 配置时间!因此,认为分享这可能会节省其他人的时间! 需要查找并更新它们以解决此问题的东西很少。

  1. 确保/var/lib/pgsql/9.6/data/pg_hba.conf 已更新如下:

  2. 确保 PostgreSQL 数据库有自己的用户 sonar 并创建了一个名为 sonar 的数据库。而且,很明显,数据库用户sonar 应该拥有这个sonar 数据库。就我而言,我将sonar 用于数据库用户和实际数据库名称,但是您可以随意使用任何名称。

  3. 确保下载并解压 SonarQube 后,将 sonarqube 移动到 /op/ 目录:

    sudo mv sonarqube-7.6 /opt/sonarqube

    然后/opt/sonarqube 目录归sonarqube linux 用户所有,在我的例子中是sonar

  4. 确保在创建和编辑/etc/systemd/system/sonar.service 文件后,它也归sonarqube linux 用户所有。

  5. /etc/systemd/system/sonar.service 文件的内容应如下所示:

    [单位]

    Description=SonarQube 服务

    After=syslog.target network.target

    [服务]

    类型=分叉

    ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start

    ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh 停止

    用户=声纳

    组=声纳

    重启=总是

    [安装]

    WantedBy=multi-user.target

    注意UserGroup 指向linux sonarqube 用户,我的是sonar。你可以是johndoe

  6. 编辑/opt/sonarqube/bin/linux-x86-64/sonar.sh并更新#RUN_AS_USER

    RUN_AS_USER=声纳

    注意这也是同一个linux sonarqube用户,我的是sonar

  7. SonarQube 似乎是一个需要 JAVA 内存的 Web 应用程序。因此,请按照此post 更新相关内存配置。请记住,该帖子基于 Centos 7.6。如果您对 linux 有不同的体验,则需要更新相关文件。

  8. 别忘了重启 PostgreSQL、Sonar Service 和 NGINX(如果你是代理传递给 Sonar)

    sudo systemctl restart postgresql-9.6 && sudo systemctl restart sonar && sudo systemctl restart nginx

  9. 检查所有这些服务的状态并确保它们都处于active/running 状态:

    sudo systemctl status postgresql-9.6 && sudo systemctl status sonar && sudo systemctl status nginx

希望对您有所帮助!

【讨论】:

  • 最完整。谢谢。
  • 更正确的 exec 行是 ExecStart=/bin/nohup /opt/java/bin/java -Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true -jar /opt/sonarqube/lib/sonar-application-7.4.jar 这是完整的单元 docs.sonarqube.org/latest/setup/operate-server 因为脚本 /opt/sonarqube/bin/linux-x86-64/sonar.sh 旨在通过 initd 在 Linux 上使用。唯一的缺点是我们需要在每次升级时更新 jar 版本。
【解决方案3】:

wheel 用户是一种 root 用户,因此我从该组中删除了 sonar 用户。之后,我无法访问保留给 root 用户的 systemctl (systemd) 命令。所以我尝试使用 sonar.sh 启动声纳,它可以工作。

感谢所有帮助我的人,我希望这篇文章可以帮助在centOS上遇到同样问题的人:)

【讨论】:

    【解决方案4】:

    我最近在使用 7.7 版时遇到了同样的问题。最初我遇到了同样的问题,服务无法正常启动,但调用 sonar.sh 脚本工作正常。

    对我有用的修复是确保服务文件引用了一个可以创建 PID 文件的目录:

    PIDFile=/opt/sonar/bin/linux-x86-64/./SonarQube.pid

    当然要确保: 在 /opt/sonar/ 上为在您的服务中调用的用户(即用户“sonar”)正确设置了权限!

    下面的完整服务文件:

    [Unit]
    Description=SonarQube application
    After=syslog.target network.target
    
    [Service]
    User=sonar
    Group=sonar
    
    Type=simple
    ExecStart=/opt/sonar/bin/linux-x86-64/sonar.sh start
    ExecStop=/opt/sonar/bin/linux-x86-64/sonar.sh stop
    ExecReload=/opt/sonar/bin/linux-x86-64/sonar.sh restart
    PIDFile=/opt/sonar/bin/linux-x86-64/./SonarQube.pid
    
    [Install]
    WantedBy=multi-user.target
    

    【讨论】:

      猜你喜欢
      • 2015-02-07
      • 1970-01-01
      • 2019-06-22
      • 1970-01-01
      • 2015-11-01
      • 2016-05-22
      • 1970-01-01
      • 2017-10-06
      • 1970-01-01
      相关资源
      最近更新 更多