
SONARQUBE 基于postgresql裸机安装
1、系统要求
1.1、服务器配置要求
- centos7
- cpu:2
- 内存:8G
- 存储:20G以上
1.2、系统参数配置
资源限制
$ vim /etc/security/limits.conf * soft nofile 65535 * hard nofile 65535 * hard nproc 4096 * soft nproc 4096内核参数配置
$ vim /etc/sysctl.conf vm.max_map_count=262144 fs.file-max=65535 net.ipv4.ip_forward = 1
2、postgresql
2.1、postgresql源配置
参考官网地址
https://www.postgresql.org/download/linux/redhat/
配置
# Install the repository RPM: sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm # Install PostgreSQL: sudo yum install -y postgresql12-server # Optionally initialize the database and enable automatic start: sudo /usr/pgsql-12/bin/postgresql-12-setup initdb sudo systemctl enable postgresql-12 sudo systemctl start postgresql-12修改postgresql配置
# 修改监听地址及端口 $ /var/lib/pgsql/12/data $ vim postgresql.conf 60 listen_addresses = '0.0.0.0' # what IP address(es) to listen on; 61 # comma-separated list of addresses; 62 # defaults to 'localhost'; use '*' for all 63 # (change requires restart) 64 port = 5432 # (change requires restart) # 重启postgresql $ systemctl restart postgresql-12.service创建sonar库
# 切换postgres用户 $ su - postgres # 登陆 -bash-4.2$ psql -U postgres psql (12.8) Type "help" for help. # 创建数据库并进行授权普通用户访问 postgres=# CREATE DATABASE sonar; # 创建数据库 CREATE DATABASE postgres=# CREATE USER sonar WITH ENCRYPTED PASSWORD '1qaz@WSX'; # 创建数据库 CREATE ROLE postgres=# GRANT ALL PRIVILEGES ON DATABASE sonar TO sonar; # 授权用户 GRANT postgres=# ALTER DATABASE sonar OWNER TO sonar; # 执行变更 ALTER DATABASE postgres=# \q开启远程访问
$ pwd /var/lib/pgsql/12/data $ vim pg_hba.conf 83 # "local" is for Unix domain socket connections only 84 local all all peer 85 local all postgres peer 86 # IPv4 local connections: 87 host all all 0.0.0.0/0 md5 88 # IPv6 local connections: 89 host all all ::1/128 md5 90 # Allow replication connections from localhost, by a user with the 91 # replication privilege. 92 local replication all peer 93 host replication all 127.0.0.1/32 md5 94 host replication all ::1/128 md5重启服务
# 启动 systemctl restart postgresql-12.service
3、sonar安装
官方下载
https://www.sonarqube.org/downloads/
3.1、创建用户
# 创建用户
$ useradd -r -m -s /bin/bash sonarqube
# 创建安装目录
$ mkdir -pv /opt/software && chown sonarqube.sonarqube /opt/software3.2、导入安装包
$ su - sonarqube
$ pwd
/opt/software
$ ll
-rw-r--r--. 1 sonarqube sonarqube 276400757 Aug 11 15:36 sonarqube-8.9.2.46101.zip
$ unzip -O CP936 sonarqube-8.9.2.46101.zip3.3、修改配置
# 配置postgresql连接信息
$ vim sonarqube-8.9.2.46101/conf/sonar.properties
18 sonar.jdbc.username=sonar
19 sonar.jdbc.password=1qaz@WSX
37 sonar.jdbc.url=jdbc:postgresql://127.0.0.1:5432/sonar3.4、启动
[sonarqube@sonar linux-x86-64]$ pwd
/opt/software/sonarqube-8.9.2.46101/bin/linux-x86-64
[sonarqube@openssh linux-x86-64]$ ./sonar.sh start3.5、查看日志

显示为启动成功
3.6、访问
地址
# 账号密码:admin/adminhttp://192.168.1.240:9000/

- 安装中文插件

- 搜索中文

- 重启服务

- 首页
