arnodzl 2019-07-31
[root@sonarqube ~]# vim /etc/sysctl.conf vm.max_map_count=262144 fs.file-max=65536 [root@sonarqube ~]# sysctl -p #生效修改的内核参数 …… vm.max_map_count = 262144 fs.file-max = 65536
[root@sonarqube ~]# vim /etc/security/limits.conf …… sonarqube - nofile 65536 sonarqube - nproc 2048
[root@sonarqube ~]# ls /usr/local/src/ jdk-8u211-linux-x64.tar.gz [root@sonarqube src]# tar xvf jdk-8u211-linux-x64.tar.gz [root@sonarqube src]#ln -sv jdk1.8.0_211 jdk [root@sonarqube src]#ln -sv jdk [root@sonarqube src]# ln -sv jdk/bin/* /usr/bin [root@sonarqube src]# vim /etc/profile …… export export LANG="en_US.utf-8" export JAVA_HOME=/usr/local/jdk export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
[root@sonarqube ~]# mkdir /data/mysql #数据库的相关数据保存路径 [root@sonarqube ~]# mkdir /data/binlog/bin #二进制日志存放目录 [root@sonarqube ~]# chown mysql.mysql -R /data/binlog [root@sonarqube ~]# chown mysql.mysql -R /data/mysql [root@sonarqube ~]# useradd -s /sbin/nologin/ mysql -u 1234
[root@sonarqube ~]# ls /apps/mysql/ mariadb-10.2.23-linux-x86_64.tar.gz
[root@sonarqube ~]# tar xvf mariadb-10.2.23-linux-x86_64.tar.gz [root@sonarqube ~]# ln -sv mariadb-10.2.23-linux-x86_64 mysql
[root@sonarqube ~]# ln -sv /apps/mysql/mysql/bin/* /usr/sbin/
[root@sonarqube ~]# vim /apps/mysql/mysql/support-files/mysql.server …… basedir=/apps/mysql/mysql #定义mysql的安装运行目录 datadir=/data/mysql #定义mysql数据库文件保存目录 ……
[root@sonarqube ~]# vim /etc/hosts 127.0.0.1 sonarqube localhost localhost.localdomain localhost4 localhost4.localdomain4 ……
[root@sonarqube scripts]# pwd /apps/mysql/mysql/scripts [root@sonarqube scripts]# ls mysql_install_db [root@sonarqube scripts]# mysql_install_db --user=mysql --datadir=/data/mysql
[root@sonarqube support-files]# pwd /apps/mysql/mysql/support-files [root@sonarqube support-files]# bash mysql.server start
[root@sonarqube ~]# ss -tnlp State Recv-Q Send-Q Local Address:Port Peer Address:Port …… LISTEN 0 80 :::3306 :::* users:(("mysqld",pid=9865,fd=18)) ……
MariaDB [(none)]> create database sonarqube default character set utf8 collate utf8_general_ci; MariaDB [(none)]> grant all on sonarqube.* to sonarqube@'192.168.1.31' identified by '123456';
[root@sonarqube ~]# mysql -usonarqube -p123456 -h192.168.1.31 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 12 Server version: 10.2.23-MariaDB-log MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | sonarqube | | test | +--------------------+ 3 rows in set (0.00 sec)
[root@sonarqube ~]# ls /apps/sonarqube sonarqube-6.7.7.zip
[root@sonarqube sonarqube]# unzip sonarqube-6.7.7.zip [root@sonarqube sonarqube]# ln -sv sonarqube-6.7.7 sonarqube ‘sonarqube’ -> ‘sonarqube-6.7.7’
[root@sonarqube sonarqube]# useradd sonarqube [root@sonarqube sonarqube]# chown sonarqube.sonarqube -R /apps/sonarqube/
[root@sonarqube conf]# su - sonarqube Last login: Mon Jul 29 13:48:33 CST 2019 on pts/1 [sonarqube@sonarqube ~]$ cd /apps/sonarqube/sonarqube [sonarqube@sonarqube sonarqube]$ grep '^[a-Z]' conf/sonar.properties sonar.jdbc.username=sonarqube sonar.jdbc.password=123456 sonar.jdbc.url=jdbc:mysql://192.168.1.31:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false sonar.web.host=0.0.0.0 sonar.web.port=9000
[sonarqube@sonarqube sonarqube]$ ./bin/linux-x86-64/sonar.sh start Starting SonarQube... Started SonarQube.
[sonarqube@sonarqube sonarqube]$ ss -tnlp State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:111 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 1 127.0.0.1:32000 *:* users:(("java",pid=10447,fd=4)) LISTEN 0 25 :::9000 :::* users:(("java",pid=10544,fd=116)) LISTEN 0 128 ::ffff:127.0.0.1:9001 :::* users:(("java",pid=10467,fd=100)) LISTEN 0 80 :::3306 :::* LISTEN 0 128 :::111 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 50 ::ffff:127.0.0.1:9092 :::* users:(("java",pid=10544,fd=148))
[sonarqube@sonarqube linux-x86-64]$ ./sonar.sh restart
[sonarqube@sonarqube sonarqube]$ ll extensions/plugins/ …… -rw-r--r-- 1 sonarqube sonarqube 38307 Jul 29 15:05 sonar-l10n-zh-plugin-1.19.jar ……
https://binaries.sonarsource.com/Distribution/sonar-scanner-cli
[root@sonarqube sonarscanner]# pwd /apps/sonarscanner [root@sonarqube sonarscanner]# ll -h total 41M -rw-r--r-- 1 root root 41M Jul 22 19:31 sonar-scanner-cli-4.0.0.1744-linux.zip
[root@sonarqube sonarscanner]# unzip sonar-scanner-cli-4.0.0.1744-linux.zip [root@sonarqube sonarscanner]# ls sonar-scanner-4.0.0.1744-linux sonar-scanner-cli-4.0.0.1744-linux.zip [root@sonarqube sonarscanner]# ln -sv sonar-scanner-4.0.0.1744-linux sonar-scanner ‘sonar-scanner’ -> ‘sonar-scanner-4.0.0.1744-linux’
[root@sonarqube sonar-scanner]# vim conf/sonar-scanner.properties …… #----- Default SonarQube server sonar.host.url=http://192.168.1.31:9000 #----- Default source code encoding sonar.sourceEncoding=UTF-8
[root@sonarqube code-test]# pwd /apps/code-test [root@sonarqube code-test]# ll -h total 6.5M -rw-r--r-- 1 root root 6.5M Nov 21 2018 sonar-examples-master.zip [root@sonarqube code-test]# unzip sonar-examples-master.zip
[root@sonarqube php-sonar-runner]# pwd /apps/code-test/sonar-examples-master/projects/languages/php/php-sonar-runner [root@sonarqube php-sonar-runner]# ll total 12 -rw-r--r-- 1 root root 453 Jul 25 2016 README.md -rw-r--r-- 1 root root 331 Jul 25 2016 sonar-project.properties drwxr-xr-x 2 root root 22 Jul 25 2016 src -rw-r--r-- 1 root root 272 Jul 25 2016 validation.txt
[root@sonarqube php-sonar-runner]# cat sonar-project.properties # Required metadata sonar.projectKey=org.sonarqube:php-simple-sq-scanner #自定义额项目key sonar.projectName=PHP :: Simple Project :: SonarQube Scanner #项目的名称 sonar.projectVersion=1.0 #项目的版本号 # Comma-separated paths to directories with sources (required) sonar.sources=src #源码路径 # Language sonar.language=php #源码的类型为PHP代码 # Encoding of the source files sonar.sourceEncoding=UTF-8 #编码的格式
[root@sonarqube php-sonar-runner]# /apps/sonarscanner/sonar-scanner/bin/sonar-scanner …… tly specify it. INFO: Calculating CPD for 1 file INFO: CPD calculation finished INFO: Analysis report generated in 213ms, dir size=34 KB INFO: Analysis reports compressed in 42ms, zip size=10 KB INFO: Analysis report uploaded in 3108ms INFO: ANALYSIS SUCCESSFUL, you can browse http://192.168.1.31:9000/dashboard/index/org.sonarqube:php-simple-sq-scanner INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report INFO: More about the report processing at http://192.168.1.31:9000/api/ce/task?id=AWw9AEUVHii-ILef0qYq INFO: Task total time: 17.226 s INFO: ------------------------------------------------------------------------ INFO: EXECUTION SUCCESS INFO: ------------------------------------------------------------------------ INFO: Total time: 29.467s INFO: Final Memory: 7M/115M INFO: ------------------------------------------------------------------------
root@Ubuntu1804:/data/src# git clone -b develop http://192.168.1.30/jie/web-page.git Cloning into 'web-page'... Username for 'http://192.168.1.30': jie Password for 'http://[email protected]': remote: Enumerating objects: 30, done. remote: Counting objects: 100% (30/30), done. remote: Compressing objects: 100% (13/13), done. remote: Total 30 (delta 4), reused 27 (delta 4) Unpacking objects: 100% (30/30), done.
root@ubuntu1804:/data/src/web-page# mv /data/Math.php ./ root@ubuntu1804:/data/src/web-page# ls index.html Math.php
root@ubuntu1804:/data/src/web-page# git add ./*
root@ubuntu1804:/data/src/web-page# git commit -m 'v11' [develop 9e106d4] v11 1 file changed, 214 insertions(+) create mode 100644 Math.php
root@ubuntu1804:/data/src/web-page# git push Username for 'http://192.168.1.30': jie Password for 'http://[email protected]': Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 1.75 KiB | 893.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) remote: remote: To create a merge request for develop, visit: remote: http://192.168.1.30/jie/web-page/merge_requests/new?merge_request%5Bsource_branch%5D=develop remote: To http://192.168.1.30/jie/web-page.git 3fb434f..9e106d4 develop -> develop