【03】SonarQube+Jenkins实现C++代码扫描-----安装sonarqube

(1) 安装mysql

1.1 安装mysql
                sudo apt update
                sudo apt install mysql-server
这样安装MySQL不会提示您设置密码或进行任何其他配置更改,使用你需要更改root用户的密码。先查看mysql安装的路径,再查看默认密码。
                cd /etc/mysql
                whereis mysql
                sudo cat debian.cnf
                mysql -u debian-sys-maint -p
                [Enter password] cXzi3iw12iQgVFw0----->根据sudo cat debian.cnf里面的password
1.2 修改root默认用户名和密码
                use mysql;
                update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost';
                update user set plugin="mysql_native_password";
                flush privileges;
                quit;
1.3 启动mysql
                sudo service mysql restart
                mysql -u root -p
                [Enter password]root
1.4 创建sonar数据库和用户
                CREATE DATABASE sonar DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
                CREATE USER 'sonar' IDENTIFIED BY 'sonar';
                GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar'; 
                GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
                FLUSH PRIVILEGES;

(2) 安装sonarqube

下载sonarqube安装包  -----> https://www.sonarqube.org

sudo unzip sonarqube-7.3.zip

(3) 配置sonarqube的环境变量

sudo vim /etc/profile
配置环境变量
export SONAR_HOME=/usr/local/sonarqube-7.3
#export SONAR_SCANNER_HOME=/usr/local/sonar-scanner-3.2.0.1227-linux
#export CPPCHECK_HOME=/usr/local/cppcheck-1.89
export PATH=$PATH:$SONAR_HOME:$SONAR_SCANNER_HOME/bin:$CPPCHECK_HOME
source /etc/profile

(4) 创建用户  ---->sonarqube不能用root权限启动

sudo groupadd sonar
sudo useradd sonar -g sonar -p sonar
sudo chown -R sonar.sonar /usr/local/sonarqube-7.3
su sonar

(5)配置sonarqube文件

sudo vim sonarqube-7.3/conf/sonar.properties
配置内容:
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.jdbc.username=root
sonar.jdbc.password=root
sonar.web.host=sonarqube安装的电脑IP
sonar.web.port=9000

 

  

posted on 2020-10-19 21:42  清宝贝,加油  阅读(425)  评论(0编辑  收藏  举报