[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 /usr/local/src/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 src]# source /etc/profile #將java環境變量生效
https://dev.mysql.com/downloads/repo/yum/
[root@sonarqube mysql.repos]# ls mysql80-community-release-el7-3.noarch.rpm [root@sonarqube mysql.repos]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm warning: mysql80-community-release-el7-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql80-community-release-el7-3 ################################# [100%]
root@sonarqube yum.repos.d]# ls CentOS-Base.repo epel.repo mysql-community.repo mysql-community-source.repo
[root@sonarqube yum.repos.d]# yum repolist all | grep mysql mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community disabled mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - disabled mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 118 mysql-connectors-community-source MySQL Connectors Community - disabled mysql-tools-community/x86_64 MySQL Tools Community enabled: 95 mysql-tools-community-source MySQL Tools Community - Sourc disabled mysql-tools-preview/x86_64 MySQL Tools Preview disabled mysql-tools-preview-source MySQL Tools Preview - Source disabled mysql55-community/x86_64 MySQL 5.5 Community Server disabled mysql55-community-source MySQL 5.5 Community Server - disabled mysql56-community/x86_64 MySQL 5.6 Community Server disabled mysql56-community-source MySQL 5.6 Community Server - disabled mysql57-community/x86_64 MySQL 5.7 Community Server disabled mysql57-community-source MySQL 5.7 Community Server - disabled mysql80-community/x86_64 MySQL 8.0 Community Server enabled: 129 mysql80-community-source MySQL 8.0 Community Server - disabled
[root@sonarqube yum.repos.d]# yum install yum-utils.noarch
[root@sonarqube yum.repos.d]# yum-config-manager --enable mysql57-community [root@sonarqube yum.repos.d]# yum-config-manager --disable mysql80-community
[root@sonarqube yum.repos.d]# yum repolist all | grep mysql mysql55-community/x86_64 MySQL 5.5 Community Server disabled mysql55-community-source MySQL 5.5 Community Server - disabled mysql56-community/x86_64 MySQL 5.6 Community Server disabled mysql56-community-source MySQL 5.6 Community Server - disabled mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 364 mysql57-community-source MySQL 5.7 Community Server - disabled mysql80-community/x86_64 MySQL 8.0 Community Server disabled mysql80-community-source MySQL 8.0 Community Server - disabled
[root@sonarqube ~]# yum install mysql mysql-server -y
[root@sonarqube ~]# mkdir /data/mysql #數據存儲目錄 [root@sonarqube ~]# mkdir /data/binlog/bin -pv #二進制日誌存儲目錄 [root@sonarqube ~]# mkdir /data/socket/ # 套接字目錄
[root@sonarqube ~]# chown mysql.mysql -R /data/mysql [root@sonarqube ~]# chown mysql.mysql -R /data/logbin/ [root@sonarqube ~]# chown mysql.mysql -R /data/socket/
[root@sonarqube ~]# ll /data total 0 drwxr-xr-x 3 mysql mysql 52 Aug 2 00:15 binlog drwxr-x--- 5 mysql mysql 314 Aug 2 00:16 mysql drwxr-xr-x 2 mysql mysql 6 Aug 2 00:19 socket
[root@sonarqube ~]# grep '^[a-z]' /etc/my.cnf log_bin=/data/binlog/bin server_id=1 datadir=/data/mysql socket=/data/socket/mysql.sock ……
[root@sonarqube ~]# systemctl restart mysqld
[root@sonarqube ~]# ss -tnlp State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* users:(("sshd",pid=3710,fd=3)) LISTEN 0 100 127.0.0.1:25 *:* users:(("master",pid=3991,fd=13)) LISTEN 0 80 :::3306 :::* users:(("mysqld",pid=22395,fd=24)) LISTEN 0 128 :::22 :::* users:(("sshd",pid=3710,fd=4)) LISTEN 0 100 ::1:25 :::* users:(("master",pid=3991,fd=14))
[root@sonarqube ~]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@sonarqube ~]# mysql -S /data/socket/mysql.sock ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@sonarqube ~]# grep 'temporary password' /var/log/mysqld.log 2019-08-01T16:29:12.727126Z 1 [Note] A temporary password is generated for root@localhost: ?B9v5Eg7eost [root@sonarqube ~]# mysql -S /data/socket/mysql.sock -p?B9v5Eg7eost #進入數據庫訪問 …… Server version: 5.7.27-log Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Jie?123456'; Query OK, 0 rows affected (0.01 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
mysql> create database sonarqube default character set utf8 collate utf8_general_ci; mysql> grant all on sonarqube.* to sonarqube@'192.168.1.31' identified by 'Jie?123456 Query OK, 0 rows affected, 1 warning (0.00 sec)
[root@sonarqube ~]# mysql -usonarqube -pJie?123456 -S /data/socket/mysql.sock -h192.168.1.31 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.27-log MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | sonarqube | +--------------------+ 2 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=Jie?123456 #登陸數據庫的密碼 sonar.jdbc.url=jdbc:mysql://192.168.1.31:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false #jdbc:mysql://192.168.1.31:3306/sonarqube 中的sonarqube爲建立的數據庫名稱 sonar.web.host=0.0.0.0 #sonarqube服務監聽本機全部ip sonar.web.port=9000 #sonarqube服務啓動時監聽的端口
[sonarqube@sonarqube sonarqube]$ ./bin/linux-x86-64/sonar.sh start Starting SonarQube... Started SonarQube.
[sonarqube@sonarqube sonarqube]$ ./bin/linux-x86-64/sonar.sh status SonarQube is not running.
[root@sonarqube logs]# tail -30 sonar.log ...... Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e0000000, 89653248, 0) failed; error='Cannot allocate memory' (errno=12) ......
[sonarqube@sonarqube sonarqube]$ ./bin/linux-x86-64/sonar.sh start 啓動服務 Starting SonarQube... Started SonarQube. [sonarqube@sonarqube sonarqube]$ ./bin/linux-x86-64/sonar.sh status #發現服務已啓動 SonarQube is running (5380).
[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://jie@192.168.1.30': 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://jie@192.168.1.30': 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