Installation and construction of sonarqube community edition under CentOS 7-the road to dream

Operating system: centos 7

sonarqube version: 7.9.5
https://docs.sonarqube.org/7.9/

JDK: 11

postgresql: 10

1. Install the database:
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 yum install -y postgresql10-server

Initialize the database:
/usr/pgsql-10/bin/postgresql-10-setup initdb

Start the database: systemctl start postgresql-10

Modify the database configuration:
vim /var/lib/pgsql/10/data/pg_hba.conf

host    all             all             0.0.0.0/0            trust

vim /var/lib/pgsql/10/data/postgresql.conf
listen_addresses = '*'

Restart the database service: systemctl restart postgresql-10

Log in to the database, create a database:
su postgres
psql
modify the administrator password:
ALTER USER postgres with encrypted password'xxxxxx';
create a user:
create user sonarqube with password'xxxxx';
create a database:
create database sonarqube owner sonarqube;
authorization:
grant all on database sonarqube to sonarqube;
view database:
\l
exit:
\q


2. System parameter optimization configuration:
create ordinary users:
useradd sonarqube
passwd sonarqube

sysctl -w  vm.max_map_count=262144
sysctl -w fs.file-max=65536
ulimit -u 4096 sonarqube
ulimit -n 65536 sonarqube


vim /etc/security/limits.conf
 
@sonarqube hard nofile 65536
@sonarqube hard nofile 65536
 

3. Upload sonarqube:
authorization:
chown -R sonarqube.sonarqube /opt/sonarqube

Modify the configuration:
cd /opt
grep -v "^#" sonarqube/conf/sonar.properties | grep -v "^$"

sonar.jdbc.username=sonarqube
sonar.jdbc.password=sonarqube
sonar.jdbc.url=jdbc:postgresql://127.0.0.1/sonarqube
sonar.web.host=0.0.0.0
sonar.web.port=9000


his sonarqube

Configure environment variables:
vim ~/.bashrc

export PATH=/opt/sonarqube/bin:$PATH

source ~/.bashrc

Start the service:
sonar.sh start

View status: sonar.sh status

4. nginx reverse proxy:

sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum install -y nginx

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Main configuration file:
user nginx;
worker_processes 1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

worker_rlimit_nofile 65535;

events {
  use epoll;
  worker_connections 65535;
  }

http {
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  server_tokens off;

  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

  access_log  /var/log/nginx/access.log  main;

  sendfile on;
  tcp_nopush on;

  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 8m;
  tcp_nodelay on;
  keepalive_timeout 65;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;

  gzip on;
  gzip_min_length 1100;
  gzip_buffers 4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 9;
  gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  gzip_vary on;

  include /etc/nginx/conf.d/*.conf;
}

vhost配置文件:
server {
    listen 80;
    server_name localhost;
    
    location / {
        proxy_pass http://127.0.0.1:9000;
        index    index.htm index.html;
    }

}


5. Firewall settings:
setenforce 0

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload


6.SonarQube Runner

https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner

https://www.jianshu.com/p/7d1c0f5dcc78

https://docs.sonarqube.org/7.9/analysis/scan/sonarscanner/

There are multiple client-side scanners

Choose to use Jenkins (https://docs.sonarqube.org/7.9/analysis/scan/sonarscanner-for-jenkins/)
or maven (https://docs.sonarqube.org/7.9/analysis/scan/ sonarscanner-for-maven/)

Guess you like

Origin blog.csdn.net/qq_34777982/article/details/110204722