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

相关推荐
赵民勇8 小时前
Linux/Unix中install命令全面用法解析
linux·shell
苏宸啊9 小时前
Linux指令篇(一)
linux·运维·服务器
我要升天!10 小时前
Linux中《网络基础》
linux·运维·网络
鸽芷咕10 小时前
【2025年度总结】时光知味,三载同行:落笔皆是沉淀,前行自有光芒
linux·c++·人工智能·2025年度总结
羑悻的小杀马特10 小时前
指尖敲代码,笔尖写成长:2025年度总结与那些没说出口的碎碎念
linux·c++·博客之星·2025年度总结
晴天¥12 小时前
VMware+Oracle linux LVM/非LVM磁盘扩容
linux·运维·服务器
oMcLin12 小时前
如何在Oracle Linux 8.4上搭建并优化Kafka集群,确保高吞吐量的实时数据流处理与消息传递?
linux·oracle·kafka
worilb12 小时前
journalctl 与 tail 使用对比
linux
UIUI12 小时前
list_for_each_entry
linux·数据结构·链表
LeenixP13 小时前
RK3576-Debian12删除userdata分区
linux·运维·服务器·数据库·debian·开发板