skip to Main Content

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


  1. Your system isn’t allowed to map enough memory for each process according to the line

    [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

    Run the following command before attempting to start SonarQube or issuing your docker compose command:

    sysctl -w vm.max_map_count=262144
    
    Login or Signup to reply.
  2. Error:

    loaded plugin [org.elasticsearch.transport.Netty4Plugin] ERROR: [1] bootstrap checks failed. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144].
    

    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,

    $ sudo sysctl -w vm.max_map_count=262144
    ========================================
    

    Output:

    $ sudo sysctl -w vm.max_map_count=262144
    vm.max_map_count = 262144
    

    To set value permanently, update the vm.max_map_count value in /etc/sysctl.conf. To verify after rebooting,

    $ sysctl vm.max_map_count
    
    Login or Signup to reply.
  3. 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 running sysctl --system and adding vm.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).

    Login or Signup to reply.
  4. 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.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: sonarqube-sonarqube-init-sysctl
      labels:
        app: sonarqube
    data:
      init_sysctl.sh: |-
        if [[ "$(sysctl -n vm.max_map_count)" -lt 524288 ]]; then
          sysctl -w vm.max_map_count=524288
        fi
        if [[ "$(sysctl -n fs.file-max)" -lt 131072 ]]; then
          sysctl -w fs.file-max=131072
        fi
        if [[ "$(ulimit -n)" != "unlimited" ]]; then
          if [[ "$(ulimit -n)" -lt 131072 ]]; then
            echo "ulimit -n 131072"
            ulimit -n 131072
          fi
        fi
        if [[ "$(ulimit -u)" != "unlimited" ]]; then
          if [[ "$(ulimit -u)" -lt 8192 ]]; then
            echo "ulimit -u 8192"
            ulimit -u 8192
          fi
        fi
    ---
    ...
      initContainers:
        - name: init-sysctl
          image: busybox:1.32
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          resources:
            {}
          command: ["sh",
                    "-e",
                    "/tmp/scripts/init_sysctl.sh"]
          volumeMounts:
            - name: init-sysctl
              mountPath: /tmp/scripts/
      containers:
        - name: sonarqube
          image: sonarqube:...
    ...
      volumes:
        - name: init-sysctl
          configMap:
            name: sonarqube-sonarqube-init-sysctl
            items:
              - key: init_sysctl.sh
                path: init_sysctl.sh
        - name: sonar-data
    

    Remark

    This answer does not exactly apply to the question, but gives a solution to the same problem when running sonarqube in kubernetes.

    Login or Signup to reply.
  5. I recommend you add args in your manifest of k8s

    -Dsonar.search.javaAdditionalOpts=-Dnode.store.allow_mmap=false

    for example:

    spec:
      containers:
        - image: sonarqube:8.8-community
          args:
            - -Dsonar.web.context=/sonar
            - -Dsonar.search.javaAdditionalOpts=-Dnode.store.allow_mmap=false
    
    Login or Signup to reply.
  6. If you are using docker o docker-compose, you must first type sysctl -w vm.max_map_count=262144 with root privileges. Or sudo 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 host

    Login or Signup to reply.
  7. If 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:

    -Dsonar.search.javaAdditionalOpts=-Dnode.store.allow_mmap=false
    

    SonarCube will launch ElasticSearch with this param

    -Dnode.store.allow_mmap=false
    

    NOTE: For ElasticSearch version < V8.x use node.store.allow_mmapfs instead

    Login or Signup to reply.
  8. 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):

    resource siteName_appsettings 'Microsoft.Web/sites/config@2020-06-01' = {
     parent: siteName_resource
     name: 'appsettings'
     properties: {
      SONARQUBE_JDBC_URL: 'xyz'
      SONARQUBE_JDBC_USERNAME: 'xyz'
      SONARQUBE_JDBC_PASSWORD: 'xyz'
      SONAR_ES_BOOTSTRAP_CHECKS_DISABLE: 'true' // <--
      'sonar.path.data': '/home/sonarqube/data' 
     }
    }
    

    see also: https://github.com/Azure/azure-quickstart-templates/pull/12519

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search