尝试使用 Postgresql 在 Linux Box 上配置 Sonarqube,sonarqube 出现错误“弹性搜索未启动,因为 ES 无法使用 root 用户运行” 下面是日志
:/opt/sonarqube/bin/linux-x86-64 # cat /opt/sonarqube/bin/linux-x86-64/sonar.sh | grep "RUN_AS_USER"
#RUN_AS_USER=sonar
if [ "X$RUN_AS_USER" != "X" ]
if [ "`$IDEXE -u -n`" = "$RUN_AS_USER" ]
**RUN_AS_USER="sonar"**
if [ "X$RUN_AS_USER" != "X" ]
# If LOCKPROP and $RUN_AS_USER are defined then the new user will most likely not be
RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1`
RUN_AS_GROUP=$RUN_AS_USER
chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE
su -m $RUN_AS_USER -c "\"$REALPATH\" $2"
#使用声纳用户运行声纳进程
sonar@:/opt/sonarqube/bin/linux-x86-64> /opt/sonarqube/bin/linux-x86-64/sonar.sh start && sleep 2s && ps aux | grep "org.elasticsearch.bootstrap.Elasticsearch"
Starting SonarQube...
/opt/sonarqube/bin/linux-x86-64/sonar.sh: line 431: /opt/sonarqube/bin/linux-x86-64/: Is a directory
Failed to start SonarQube.
sonar 6344 0.0 0.0 8964 988 pts/0 S+ 14:07 0:00 grep --color=auto org.elasticsearch.bootstrap.Elasticsearch
#声纳日志
# tail -f /opt/sonarqube/logs/sonar.log
2021.03.16 08:06:17 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2021.03.16 08:06:17 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch
2021.03.16 08:06:17 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2021.03.16 08:06:18 INFO app[][o.e.p.PluginsService] no modules loaded
2021.03.16 08:06:18 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
2021.03.16 08:06:21 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1
2021.03.16 08:06:21 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
2021.03.16 08:06:21 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped
sonar@:/opt/sonarqube/bin/linux-x86-64> tail -f /opt/sonarqube/logs/es.log
Caused by: java.lang.RuntimeException: can not run elasticsearch as root