I’m trying to setup SonarQube 7.9.1 community edition with postgres on centos 7 but when I start the service, it fails.
I want to setup SonarQube with postgres on centos 7 but I can’t. I already tried to setup with docker and I get same result. The only way to start SonarQube is with H2 embebed but it works just for testing purpose.
This is the only error that log shows
2019.07.17 05:52:11 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp
2019.07.17 05:52:11 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2019.07.17 05:52:12 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch
2019.07.17 05:52:12 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2019.07.17 05:52:12 INFO app[][o.e.p.PluginsService] no modules loaded
2019.07.17 05:52:12 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.
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
2019.07.17 05:52:19 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 78
2019.07.17 05:52:19 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
2019.07.17 05:52:19 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
I don’t know why the service died but I hope to setup the service with postgres.
8
Answers
Your system isn’t allowed to map enough memory for each process according to the line
Run the following command before attempting to start SonarQube or issuing your
docker compose
command:Error:
Solution:
Elasticsearch uses a MMap FS directory to store its indices. The default operating system limits on mmap counts is possibly to be too low, which may result in out of memory exceptions. Enter the below command to increase virtual memory value using sudo privileges,
Output:
To set value permanently, update the vm.max_map_count value in /etc/sysctl.conf. To verify after rebooting,
This answer does not provide a solution but it may shed some light on why some people might not be able to get elsaticsearch up and running on their virtual server.
I have the same problem, but I am not able to change the value
vm.max_map_count
. I receive the error when runningsysctl --system
and addingvm.max_map_count=262144
into file/usr/lib/sysctl.d/99-elasticsearch.conf
* Applying /usr/lib/sysctl.d/99-elasticsearch.conf ...
sysctl: setting key "vm.max_map_count": Datei oder Verzeichnis nicht gefunden
After investing some time it turns out that my virtual CentOS7 server is running on WSL. And WSL does not support setting of all kernel parameters, and
vm.max_map_count
is one of it (https://github.com/microsoft/WSL/issues/3126#issuecomment-396271872).The provided answers show how you can set the values on the host system.
My answer shows how you can set the values in an kubernetes init container, if you can’t set system values on the host system itself.
This solution is taken from the sonarqube helm chart.
If you are using helm you might want to use the sonarqube helm chart itself, which includes the solution already.
Remark
This answer does not exactly apply to the question, but gives a solution to the same problem when running sonarqube in kubernetes.
I recommend you add args in your manifest of k8s
for example:
If you are using docker o docker-compose, you must first type
sysctl -w vm.max_map_count=262144
with root privileges. Orsudo sysctl -w vm.max_map_count=262144
in host machine, then you start a new container (must be new, restart not work), so when it begin take the configuration from the hostIf you are using Azure AppService or other Docker service, most probably is that you can’t change de host OS values with sysctl
In that case, you can change the ElasticSearch configuration, disabling memory mapping, setting this variable in the java execution of SonarQube, this variable will pass it’s value as a Java parameter when launching ElasticSearch:
SonarCube will launch ElasticSearch with this param
NOTE: For ElasticSearch version < V8.x use node.store.allow_mmapfs instead
I tried it out and it finally works again with Version
9.4-community
I set the variable
SONAR_ES_BOOTSTRAP_CHECKS_DISABLE
to true.Bicep (ARM):
see also: https://github.com/Azure/azure-quickstart-templates/pull/12519