1 安装数据库: centos8: sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm sudo dnf -qy module disable postgresql sudo dnf install -y postgresql14-server sudo /usr/pgsql-14/bin/postgresql-14-setup initdb sudo systemctl enable postgresql-14 sudo systemctl start postgresql-14
centos7: sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm sudo yum install -y postgresql13-server
vim /usr/lib/systemd/system/postgresql-13.service? Environment=PGDATA=/data/pgsql/13/data sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
vim /var/lib/pgsql/13/data/postgresql.conf
listen_addresses = '*' ? ? ? ? ?# what IP address(es) to listen on; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # comma-separated list of addresses; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # defaults to 'localhost'; use '*' for all ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # (change requires restart) port = 5432 ? vim /var/lib/pgsql/13/data/pg_hba.conf host ? ?all ? ? ? ? ? ? all ? ? ? ? ? ? 192.168.88.0/24 ? ? ? ? password
sudo systemctl enable postgresql-13 sudo systemctl restart postgresql-13 su - postgres # 新建postgres数据库用户 sonar createuser sonar ?# 创建用户 # 登录数据库 psql # 创建数据库sonar CREATE DATABASE sonar WITH ENCODING 'UTF8' OWNER sonar TEMPLATE=template0;
alter user sonar with password 'sonar'; ? ? ? ? ? #设置sonar用户密码(否则会导致连不上数据库) alter role sonar createdb;alter role sonar superuser;alter role sonar createrole; ? ?#给sonar授权 alter database sonar owner to sonar; ? ? ?#更改sonar数据库拥有者(这一步是必须的,否则会sonarqube会连接失败) # 退出数据库连接 \q
2.安装sonarqube useradd sonar? chown sonar.sonar -R sonarqube-8.9.7.52159 unzip sonarqube-8.9.7.52159.zip? cd sonarqube-8.9.7.52159/conf/ 修改配置文件 vi sonar.properties sonar.jdbc.username=sonar sonar.jdbc.password=sonar sonar.jdbc.url=jdbc:postgresql://localhost/sonar sonar.web.host=192.168.88.88 sonar.web.port=9000
设置系统参数 sysctl -w vm.max_map_count=524288 sysctl -w fs.file-max=131072 ulimit -n 131072 ulimit -u 8192 永久设置,修改/etc/sysctl.d/99-sonarqube.conf(或/etc/sysctl.conf文件): vi /etc/sysctl.conf vm.max_map_count=524288 fs.file-max=131072 启动:
cd /data/sonarqube-8.9.7.52159/bin/linux-x86-64 ./sonar.sh start?
安装sonar-scanner unzip sonar-scanner-cli-4.7.0.2747-linux.zip? ln -s /data/sonar-scanner-4.7.0.2747-linux/bin/sonar-scanner /usr/bin/sonar-scanner vim /data/sonar-scanner-4.7.0.2747-linux/conf/sonar-scanner.properties?
#----- Default SonarQube server sonar.host.url=http://localhost:9000
#----- Default source code encoding sonar.sourceEncoding=UTF-8
?
|