• sonarqube7.9安装部署(linux)


    0.参考文档

    LTS 7.9.1 新特性:

      https://www.sonarqube.org/downloads/

    JDK11 下载地址:

      参考https://www.cnblogs.com/schblog/p/13287799.html

    1.下载软件包

    下载链接: https://www.sonarqube.org/downloads/

    2.添加系统用户

    1
    2
    useradd sonarqube
    passwd sonarqube

    3.优化系统参数

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

    永久修改系统参数:

    1.vi /etc/sysctl.conf
    在最后增加两行:
    vm.max_map_count=262144
    fs.file-max=65536

    然后再控制台输入sysctl -p 写入内存,即可立即生效
    2.vi /etc/security/limits.conf

    *          soft   nofile        65536
    * hard nofile 65536
    @sonarqube soft noproc 4096
    @sonarqube hard noproc 4096

    截图如下:

    sysctl.conf文件:

    limits.conf文件:

    4.解压安装包

    1
    2
    3
    4
    5
    mv sonarqube-7.9.1.zip  /home/sonarqube/
    chown -R sonarqube:sonarqube /home/sonarqube/
    su - sonarqube
    yum -y install unzip
    unzip sonarqube-7.9.1.zip

    5.更改配置文件

    1
    2
    3
    4
    5
    6
    vim sonarqube-7.9.1/conf/sonar.properties
     
    [sonarqube@localhost ~]$ grep -v "^#" sonarqube-7.9.1/conf/sonar.properties | grep -v "^$"
    sonar.jdbc.username=sonarqube
    sonar.jdbc.password=meiyoumima
    sonar.jdbc.url=jdbc:postgresql://127.0.0.1/sonarqube

    6.安装PostgreSQL#下载pg9.6 源

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    <em id="__mceDel">yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
    yum install postgresql96-server postgresql96-contrib
    #初始化db
    /usr/pgsql-9.6/bin/postgresql96-setup initdb
     
    #启动服务、开机自启
    systemctl start postgresql-9.6
    systemctl enable postgresql-9.6
     
    #防火墙
    firewall-cmd --add-service=postgresql --permanent
    firewall-cmd --reload
         
    #登录数据库
    su - postgres
    psql -U postgres
    ALTER USER postgres with encrypted password 'xxxxxx';
    q
    exit<br><br>#创建sonarqube用户<br>create user sonarqube with password 'xxxxx';<br>create database sonarqube owner sonarqube;<br>grant all  on database sonarqube to sonarqube;<br>create schema my_schema;<br>
     
    #开启远程访问
    vi /var/lib/pgsql/9.6/data/postgresql.conf   #listen_addresses = '*' 
    vi /var/lib/pgsql/9.6/data/pg_hba.conf<br><br>
    systemctl restart postgresql-9.6.service<br><br>#pg_hba.conf</em>
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # IPv4 local connections:
    host    all             all             0.0.0.0/0            trust
    # IPv6 local connections:
    host    all             all             ::1/128                 ident
    # Allow replication connections from localhost, by a user with the
    # replication privilege.
    #local   replication     postgres                                peer
    #host    replication     postgres        127.0.0.1/32            ident
    #host    replication     postgres        ::1/128                 ident
    host    all     all       0.0.0.0/0                ident

    7.添加系统服务

    配置服务参考官网:https://docs.sonarqube.org/7.9/setup/operate-server/

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    ln -s /home/sonarqube/sonarqube-7.9.1/bin/linux-x86-64/sonar.sh  /usr/bin/sonar
     
    vim /etc/init.d/sonarqube
     
     
     
    #!/bin/sh
    #
    # rc file for SonarQube
    #
    # chkconfig: 345 96 10
    # description: SonarQube system (www.sonarsource.org)
    #
    ### BEGIN INIT INFO
    # Provides: sonar
    # Required-Start: $network
    # Required-Stop: $network
    # Default-Start: 3 4 5
    # Default-Stop: 0 1 2 6
    # Short-Description: SonarQube system (www.sonarsource.org)
    # Description: SonarQube system (www.sonarsource.org)
    ### END INIT INFO
     
    /usr/bin/sonar $*
     
     
     
    chkconfig --add sonarqube
    chkconfig sonarqube on
     
    service sonarqube status

    8.FAQ

    1. JDK11错误: 需要安装JDK11

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    [sonarqube@localhost linux-x86-64]$ ./sonar.sh  console
    Running SonarQube...
    wrapper  | --> Wrapper Started as Console
    wrapper  | Launching a JVM...
    jvm 1    | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
    jvm 1    |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
    jvm 1    |
    jvm 1    | 20:46:06.753 [WrapperSimpleAppMain] WARN org.sonar.application.config.JdbcSettings - JDBC URL is recommended to have the property 'rewriteBatchedStatements=true'
    jvm 1    | 20:46:06.764 [WrapperSimpleAppMain] WARN org.sonar.application.config.JdbcSettings - JDBC URL is recommended to have the property 'useConfigs=maxPerformance'
    jvm 1    |
    jvm 1    | WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: SonarQube requires Java 11+ to run
    jvm 1    | java.lang.IllegalStateException: SonarQube requires Java 11+ to run
    jvm 1    |      at org.sonar.application.App.checkJavaVersion(App.java:93)
    jvm 1    |      at org.sonar.application.App.start(App.java:56)
    jvm 1    |      at org.sonar.application.App.main(App.java:98)
    jvm 1    |      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    jvm 1    |      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    jvm 1    |      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    jvm 1    |      at java.lang.reflect.Method.invoke(Method.java:498)
    jvm 1    |      at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
    jvm 1    |      at java.lang.Thread.run(Thread.java:748)
    wrapper  | <-- Wrapper Stopped

    2.MySQL数据库不支持

    参考:https://www.cnblogs.com/mascot1/p/11179767.html

  • 相关阅读:
    65 组件 静态文件相关 视图
    作者和书籍的增删改查 多对多
    64 装饰器函数: 母版 csrf防御机制 cookie
    61 书籍和出版社 的增删改查 几秒后跳转一个页面
    60 Django项目 单表(出版社)的增删改查 __str__方法及格式化输出 的两个方法
    模块 itertools
    59 Django基础三件套 , 模板{{}}语言 , 程序连mysql Django项目app Django中ORM的使用
    nginx 并发数
    设置tomcat最大内存
    goaccess安装
  • 原文地址:https://www.cnblogs.com/schblog/p/14039417.html
Copyright © 2020-2023  润新知