CentOS 7上安装SonarQube10

在CentOS 7上安装SonarQube10并使用PostgreSQL作为数据库

⚠️ 重要注意事项

  1. 不再支持:MySQL 数据库(从 SonarQube 7.9 开始已移除)

  2. 数据库驱动:不需要手动安装,SonarQube 已包含

  3. 字符集:所有数据库必须使用 UTF-8 编码

  4. 权限:需要为 SonarQube 创建专用数据库用户

安装SonarQube(之前需要安装postgreSql)

安装SonarQube

yum install -y epel-release

创建sonarqube用户

sudo useradd sonarqube

创建系统用户和组

useradd -r -s /bin/bash sonarqube

sudo groupadd sonarqube

删除用户和组(如果需要)

sudo userdel -r sonarqube

sudo groupdel -f sonarqube

安装unzip(如果没有)

sudo yum install -y unzip

解压

unzip sonarqube-10.0.0.68432.zip

mv sonarqube-10.0.0.68432 sonarqube

设置权限

sudo chown -R sonarqube:sonarqube /opt/sonarqube

sudo chmod -R 755 /opt/sonarqube

配置系统参数

sudo vi /etc/security/limits.conf

sonarqube soft nofile 65536

sonarqube hard nofile 65536

sonarqube soft nproc 4096

sonarqube hard nproc 4096

修改sysctl配置

sudo vi /etc/sysctl.conf

vm.max_map_count=262144

fs.file-max=65536

应用配置:

sudo sysctl -p

创建Systemd服务

创建服务文件

sudo vi /etc/systemd/system/sonarqube.service

添加以下内容:

Unit

Description=SonarQube service

After=syslog.target network.target postgresql-14.service

Service

Type=forking

User=sonarqube

Group=sonarqube

PermissionsStartOnly=true

ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start

ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop

ExecReload=/opt/sonarqube/bin/linux-x86-64/sonar.sh restart

LimitNOFILE=65536

LimitNPROC=4096

Restart=on-failure

Install

WantedBy=multi-user.target

启动SonarQube

重新加载systemd

sudo systemctl daemon-reload

启动SonarQube服务

sudo systemctl start sonarqube

设置开机自启

sudo systemctl enable sonarqube

检查状态

sudo systemctl status sonarqube

查看日志

sudo tail -f /opt/sonarqube/logs/sonar.log

给sonarqube用户添加密码

sudo passwd sonarqube

wa123456

端口

sonar.web.port=9000

访问SonarQube

http://your-server-ip:9000

内存不足问题

编辑 vim /opt/sonarqube/conf/sonar.properties:

sonar.web.javaOpts=-Xmx2G -Xms128m -XX:+HeapDumpOnOutOfMemoryError

编辑服务文件

sudo systemctl edit sonarqube

添加以下内容来放宽启动限制

Service

StartLimitInterval=0

StartLimitBurst=0

Unit

StartLimitIntervalSec=0

Java not found. Please make sure that the environmental variable SONAR_JAVA_PATH 错误处理

编辑sonar.sh文件

sudo vi /opt/sonarqube/bin/linux-x86-64/sonar.sh

在顶部添加

SONAR_JAVA_PATH="$JAVA_HOME/bin/java"

登录 : http://192.168.88.128:9000/

默认用户名 admin

默认密码 admin

修改密码 :admin@123

相关推荐
小白兔奶糖ovo10 分钟前
【Leetcode】231. 2的幂
linux·算法·leetcode
s_w.h35 分钟前
【 linux 】动静态库的制作
linux·运维·服务器·算法·bash
顺风尿一寸1 小时前
深入Linux内核:mkdir系统调用的完整实现解析
linux
用户2367829801681 小时前
Linux free 命令深度解析:从内存监控到 OOM 排查的完整指南
linux
无足鸟ICT2 小时前
【RHCA+】boxes命令(艺术框)
linux
_Voosk2 小时前
FreeBSD 使用代理运行命令
linux·运维·freebsd
G_dou_2 小时前
Linux 搭建 Rust 开发环境:从 rustup 安装到 Cargo 镜像
linux·rust
bsauce3 小时前
【kernel exploit】CVE-2026-23271 perf_event竞态UAF漏洞-ROP提权
linux·linux内核·内核漏洞·内核漏洞利用
Hehuyi_In4 小时前
从优雅到爆烈 —— Linux全力回收内存的一生
linux·内核·内存·memory·回收
杨充4 小时前
1.1 数据编码设计原理
linux·运维·网络·底层原理·数据编码