0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SonarQubeでvm.max_map_countのエラーが出た時の対処法

Posted at

docker-composeでSonarQubeを起動した時にvm.max_map_countに関するエラーが出て躓いたので、備忘録がてら記録。

SonarQubeの起動

以下のdocker-compose.ymlを作成。9000ポートは別のアプリ(MinIO)で利用していたので9999ポートを利用。

version: "3"
services:
  sonarqube:
    image: sonarqube:community
    hostname: sonarqube
    container_name: sonarqube
    depends_on:
      - db
    environment:
      SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
      SONAR_JDBC_USERNAME: sonar
      SONAR_JDBC_PASSWORD: sonar
    volumes:
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions
      - sonarqube_logs:/opt/sonarqube/logs
    ports:
    - "0.0.0.0:9999:9000"
  db:
    image: postgres:13
    hostname: postgresql
    container_name: postgresql
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: sonar
      POSTGRES_DB: sonar
    volumes:
      - postgresql:/var/lib/postgresql
      - postgresql_data:/var/lib/postgresql/data

volumes:
  sonarqube_data:
  sonarqube_extensions:
  sonarqube_logs:
  postgresql:
  postgresql_data:

以下のスクリプト経由で起動。

#!/bin/bash
set -ex
if [ "$1" == "up" ]; then
  docker-compose up -d --build
elif [ "$1" == "down" ]; then
  docker-compose down
fi

この状態でlocalhost:9999にcurlしても通らない。
docker logsで状態を確認する。

$ docker logs 862e55b4b91e
:(省略)
[2023/04/24 8:23:55.829 AM] bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2023/04/24 8:23:55.829 AM] ERROR: Elasticsearch did not exit normally - check the logs at /opt/sonarqube/logs/sonarqube.log
:(省略)
2023.04.23 23:36:03 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2023.04.23 23:36:03 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped

ElasticSearchが落ちていた。プロセスが利用可能なマップ領域が不足している模様。
検索すると、以下の文献が見つかった。
Elasticsearch の max_map_count パラメータの変更

/etc/sysctl.confvm.max_map_count = 262144を追記して再起動する。
今度は無事にcurlが通った。

$ curl localhost:9999

<!DOCTYPE html>
<html lang="en">
:(省略)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?