SONARQUBE 基于postgresql裸机安装

captains 2021-08-13 PM 2309℃ 0条

sonar.jpg

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/software

3.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.zip

3.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/sonar

3.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 start

3.5、查看日志

image-20210813143715365

显示为启动成功

3.6、访问

  • 地址

    # 账号密码:admin/adminhttp://192.168.1.240:9000/

image-20210813144023741

  • 安装中文插件

image-20210813144227165

  • 搜索中文

image-20210813145531578

  • 重启服务

image-20210813145607769

  • 首页

image-20210813145749806

标签: SONARQUBE

非特殊说明,本博所有文章均为博主原创。

评论啦~