以Docker-compose 的方式启动SonarQube

docker-compose 启动sonarqube

sonarqube 关联不上postgres 数据库 可能是因为镜像的问题 以下两个镜像是可以关联上的

docker network create sonar

mkdir -pv /sonar/postgres/data
mkdir -pv /sonar/sonarqube/logs
mkdir -pv /sonar/sonarqube/data
mkdir -pv /sonar/sonarqube/extensions
chmod 777 -R /sonar/sonarqube

echo "vm.max_map_count=262144" > /etc/sysctl.conf
sysctl -p
version: '3'
services:
  postgres:
    image: postgres:13
    container_name: postgres
    restart: always
    privileged: true
    networks:
      - sonar
    volumes:
      - /sonar/postgres/data:/var/lib/postgresql/data
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_USER=sonar 
      - POSTGRES_PASSWORD=sonar 
      - POSTGRES_DB=sonar 
      - TZ=Asia/Shanghai 

  sonar:
    image: sonarqube:8.9-community
    container_name: sonar
    restart: always
    privileged: true
    networks:
      - sonar
    volumes:
      - /sonar/sonarqube/logs:/opt/sonarqube/logs
      - /sonar/sonarqube/data:/opt/sonarqube/data
      - /sonar/sonarqube/extensions:/opt/sonarqube/extensions
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "9000:9000"
    depends_on:
      - postgres
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - SONARQUBE_JDBC_USERNAME=sonar
      - SONARQUBE_JDBC_PASSWORD=sonar
      - SONARQUBE_JDBC_URL=jdbc:postgresql://192.168.0.206:5432/sonar
      - PGDATA=/var/lib/postgresql/data/pgdata
      - TZ=Asia/Shanghai


networks:
  sonar:
    driver: bridge

浏览器访问 ip +9000 端口

http://192.168.16.206:9000
初始使用 admin/admin 登录

故障排除

要查看容器的日志

docker logs sonarqube

报错一

ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

您将需要增加可用的内存区域。

临时修改

sysctl -w vm.max_map_count=262144

查看结果

sysctl -a|grep vm.max_map_count

永久修改

vim /etc/sysctl.conf

添加下行。

vm.max_map_count=262144

使生效

sysctl -p

报错二

uncaught exception in thread [main]
java.lang.IllegalStateException: Unable to access 'path.data' (/opt/sonarqube/data/es7)
Likely root cause: java.nio.file.AccessDeniedException: /opt/sonarqube/data/es7

把sonarqube映射的目录加权限

chmod 777 -R /sonar/sonarqube

汉化

安装中文包

重启服务

汉化完成

posted @ 2023-05-24 09:46  买定灬离手  阅读(689)  评论(0编辑  收藏  举报