服務器系統:CentOS 7
服務器/home/azrlnx04/下創建三個文件夾,/java 、/mysql、 /sonar
安裝sonarQube之前,需要先安裝JDK和mysql
整體的步驟是:
- 安裝JDK支持
- 安裝mySQL數據庫
- 安裝SonarQube
一:安裝JDK
(1)打開http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 選擇Linux x64 159.97 MB jdk-8u112-linux-x64.rpm,下載至windows系統的下載目錄
(2)將rpm文件通過WinSCP(遠程復制文件工具)復制至/java文件夾
(3)使用命令為rpm文件加入權限
cd /home/azrlnx04/java/
chmod 777 jdk-8u111-linux-x64.rpm
(4)使用命令安裝rpm文件
sudo rpm -ivh jdk-8u111-linux-x64.rpm
(5)使用命令檢查jdk
java -version
如果出現了版本號,則是成功的
[azrlnx04@azrlnx04 ~]$ java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode) [azrlnx04@azrlnx04 ~]$
(6)加入至環境變量中,雖然能夠正常的使用命令,則還需要加入用戶的環境變量中,參考文章http://www.cnblogs.com/samcn/archive/2011/03/16/1986248.html
因權限的問題,當前用戶只有部分權限,所以使用第二種方法(操作和修改.bash_profile文件)這樣可以將權限加入控制在用戶級別
在用戶的主目錄,使用命令 vi .bash_profile可以打開文件,按下Insert鍵可以進行操作
修改前
export PATH
修改后
export PATH export JAVA_HOME=/usr/bin/java export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=./$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
關於怎么得到jdk的地址,我們可以使用命令 whereis java即可以得到地址,修改文件后,按Esc鍵,加入命令:wq再回車,即可保存當前修改
(7)測試文件,用文本編輯器在windows下新建一個Test.java文件,輸入以下代碼並保存再復制至當前系統中
public class test { public static void main(String args[]) { System.out.println("A new jdk test !"); } }
使用命令,如果系統能夠打印出“A new jdk test !”這個文本則是成功的
javac test.java
java test
二:安裝mysql
參考mysql官方文檔 http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
(1)http://dev.mysql.com/downloads/repo/yum/ 下載 Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package(mysql57-community-release-el7-9.noarch.rpm) , rpm文檔很小,也是下載至Windows系統本地目錄
(2)將下載的mysql57-community-release-el7-9.noarch.rpm復制至/mysql中
(3)運行命令為文件加入權限
chmod 777 mysql57-community-release-el7-9.noarch.rpm
(4)運行安裝文件
sudo yum localinstall mysql57-community-release-el7-9.noarch.rpm
服務器回應

[azrlnx04@azrlnx04 mysql]$ sudo yum localinstall mysql57-community-release-el7-9.noarch.rpm [sudo] password for azrlnx04: Loaded plugins: fastestmirror, langpacks Examining mysql57-community-release-el7-9.noarch.rpm: mysql57-community-release-el7-9.noarch Marking mysql57-community-release-el7-9.noarch.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package mysql57-community-release.noarch 0:el7-9 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================ Package Arch Version Repository Size ================================================================================================================================================================ Installing: mysql57-community-release noarch el7-9 /mysql57-community-release-el7-9.noarch 8.6 k Transaction Summary ================================================================================================================================================================ Install 1 Package Total size: 8.6 k Installed size: 8.6 k Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mysql57-community-release-el7-9.noarch 1/1 Verifying : mysql57-community-release-el7-9.noarch 1/1 Installed: mysql57-community-release.noarch 0:el7-9 Complete!
(5)使用yum命令查看mysql,應該可以查看至很多關於mysql的包可供安裝
yum repolist all | grep mysql
服務器回應

[azrlnx04@azrlnx04 mysql]$ yum list | grep mysql mysql-community-client.x86_64 5.7.16-1.el7 @mysql57-community mysql-community-common.x86_64 5.7.16-1.el7 @mysql57-community mysql-community-devel.x86_64 5.7.16-1.el7 @mysql57-community mysql-community-libs.x86_64 5.7.16-1.el7 @mysql57-community mysql-community-libs-compat.x86_64 5.7.16-1.el7 @mysql57-community mysql-community-server.x86_64 5.7.16-1.el7 @mysql57-community mysql57-community-release.noarch el7-9 @/mysql57-community-release-el7-9.noarch akonadi-mysql.x86_64 1.9.2-4.el7 base apr-util-mysql.x86_64 1.5.2-6.el7 base dovecot-mysql.x86_64 1:2.2.10-5.el7 base freeradius-mysql.x86_64 3.0.4-6.el7 base libdbi-dbd-mysql.x86_64 0.8.3-16.el7 base mysql-community-client.i686 5.7.16-1.el7 mysql57-community mysql-community-common.i686 5.7.16-1.el7 mysql57-community mysql-community-devel.i686 5.7.16-1.el7 mysql57-community mysql-community-embedded.i686 5.7.16-1.el7 mysql57-community mysql-community-embedded.x86_64 5.7.16-1.el7 mysql57-community mysql-community-embedded-compat.i686 5.7.16-1.el7 mysql57-community mysql-community-embedded-compat.x86_64 5.7.16-1.el7 mysql57-community mysql-community-embedded-devel.i686 5.7.16-1.el7 mysql57-community mysql-community-embedded-devel.x86_64 5.7.16-1.el7 mysql57-community mysql-community-libs.i686 5.7.16-1.el7 mysql57-community mysql-community-libs-compat.i686 5.7.16-1.el7 mysql57-community mysql-community-release.noarch el7-7 mysql57-community mysql-community-test.x86_64 5.7.16-1.el7 mysql57-community mysql-connector-java.noarch 1:5.1.25-3.el7 base mysql-connector-odbc.x86_64 5.3.6-1.el7 mysql-connectors-community mysql-connector-odbc-debuginfo.x86_64 5.3.6-1.el7 mysql-connectors-community mysql-connector-odbc-setup.x86_64 5.3.6-1.el7 mysql-connectors-community mysql-connector-python.noarch 2.0.4-1.el7 mysql-connectors-community mysql-connector-python.x86_64 2.1.4-1.el7 mysql-connectors-community mysql-connector-python-cext.x86_64 2.1.4-1.el7 mysql-connectors-community mysql-connector-python-debuginfo.x86_64 2.1.4-1.el7 mysql-connectors-community mysql-router.x86_64 2.0.3-1.el7 mysql-tools-community mysql-router-debuginfo.x86_64 2.0.3-1.el7 mysql-tools-community mysql-utilities.noarch 1.6.4-1.el7 mysql-tools-community mysql-utilities-extra.noarch 1.5.6-1.el7 mysql-tools-community mysql-workbench-community.x86_64 6.3.8-1.el7 mysql-tools-community mysql-workbench-community-debuginfo.x86_64 6.3.8-1.el7 mysql-tools-community
(6)安裝mysql,我們這里安裝的是mysql 5.7.16
sudo yum install mysql-community-server
服務器回應

[azrlnx04@azrlnx04 mysql]$ sudo yum install mysql-community-server Loaded plugins: fastestmirror, langpacks mysql-connectors-community | 2.5 kB 00:00:00 mysql-tools-community | 2.5 kB 00:00:00 mysql57-community | 2.5 kB 00:00:00 (1/3): mysql-tools-community/x86_64/primary_db | 29 kB 00:00:00 (2/3): mysql57-community/x86_64/primary_db | 86 kB 00:00:00 (3/3): mysql-connectors-community/x86_64/primary_db | 11 kB 00:00:00 Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package mysql-community-server.x86_64 0:5.7.16-1.el7 will be installed --> Processing Dependency: mysql-community-common(x86-64) = 5.7.16-1.el7 for package: mysql-community-server-5.7.16-1.el7.x86_64 --> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.16-1.el7.x86_64 --> Running transaction check ---> Package mariadb.x86_64 1:5.5.50-1.el7_2 will be obsoleted ---> Package mysql-community-client.x86_64 0:5.7.16-1.el7 will be obsoleting --> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.16-1.el7.x86_64 ---> Package mysql-community-common.x86_64 0:5.7.16-1.el7 will be installed --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.50-1.el7_2 will be obsoleted --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:mariadb-devel-5.5.50-1.el7_2.x86_64 --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 --> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.50-1.el7_2 for package: 1:mariadb-devel-5.5.50-1.el7_2.x86_64 ---> Package mysql-community-libs.x86_64 0:5.7.16-1.el7 will be obsoleting --> Running transaction check ---> Package mariadb-devel.x86_64 1:5.5.50-1.el7_2 will be obsoleted ---> Package mysql-community-devel.x86_64 0:5.7.16-1.el7 will be obsoleting ---> Package mysql-community-libs-compat.x86_64 0:5.7.16-1.el7 will be obsoleting --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================ Package Arch Version Repository Size ================================================================================================================================================================ Installing: mysql-community-client x86_64 5.7.16-1.el7 mysql57-community 24 M replacing mariadb.x86_64 1:5.5.50-1.el7_2 mysql-community-devel x86_64 5.7.16-1.el7 mysql57-community 3.6 M replacing mariadb-devel.x86_64 1:5.5.50-1.el7_2 mysql-community-libs x86_64 5.7.16-1.el7 mysql57-community 2.1 M replacing mariadb-libs.x86_64 1:5.5.50-1.el7_2 mysql-community-libs-compat x86_64 5.7.16-1.el7 mysql57-community 2.0 M replacing mariadb-libs.x86_64 1:5.5.50-1.el7_2 mysql-community-server x86_64 5.7.16-1.el7 mysql57-community 152 M Installing for dependencies: mysql-community-common x86_64 5.7.16-1.el7 mysql57-community 271 k Transaction Summary ================================================================================================================================================================ Install 5 Packages (+1 Dependent package) Total download size: 184 M Is this ok [y/d/N]: y Downloading packages: warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Public key for mysql-community-common-5.7.16-1.el7.x86_64.rpm is not installed (1/6): mysql-community-common-5.7.16-1.el7.x86_64.rpm | 271 kB 00:00:00 (2/6): mysql-community-devel-5.7.16-1.el7.x86_64.rpm | 3.6 MB 00:00:00 (3/6): mysql-community-libs-5.7.16-1.el7.x86_64.rpm | 2.1 MB 00:00:00 (4/6): mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm | 2.0 MB 00:00:02 (5/6): mysql-community-server-5.7.16-1.el7.x86_64.rpm | 152 MB 00:00:06 (6/6): mysql-community-client-5.7.16-1.el7.x86_64.rpm | 24 MB 00:00:20 ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 9.0 MB/s | 184 MB 00:00:20 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Importing GPG key 0x5072E1F5: Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>" Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 Package : mysql57-community-release-el7-9.noarch (@/mysql57-community-release-el7-9.noarch) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mysql-community-common-5.7.16-1.el7.x86_64 1/9 Installing : mysql-community-libs-5.7.16-1.el7.x86_64 2/9 Installing : mysql-community-client-5.7.16-1.el7.x86_64 3/9 Installing : mysql-community-server-5.7.16-1.el7.x86_64 4/9 Installing : mysql-community-libs-compat-5.7.16-1.el7.x86_64 5/9 Installing : mysql-community-devel-5.7.16-1.el7.x86_64 6/9 Erasing : 1:mariadb-devel-5.5.50-1.el7_2.x86_64 7/9 Erasing : 1:mariadb-5.5.50-1.el7_2.x86_64 8/9 Erasing : 1:mariadb-libs-5.5.50-1.el7_2.x86_64 9/9 Verifying : mysql-community-libs-5.7.16-1.el7.x86_64 1/9 Verifying : mysql-community-libs-compat-5.7.16-1.el7.x86_64 2/9 Verifying : mysql-community-client-5.7.16-1.el7.x86_64 3/9 Verifying : mysql-community-devel-5.7.16-1.el7.x86_64 4/9 Verifying : mysql-community-common-5.7.16-1.el7.x86_64 5/9 Verifying : mysql-community-server-5.7.16-1.el7.x86_64 6/9 Verifying : 1:mariadb-devel-5.5.50-1.el7_2.x86_64 7/9 Verifying : 1:mariadb-libs-5.5.50-1.el7_2.x86_64 8/9 Verifying : 1:mariadb-5.5.50-1.el7_2.x86_64 9/9 Installed: mysql-community-client.x86_64 0:5.7.16-1.el7 mysql-community-devel.x86_64 0:5.7.16-1.el7 mysql-community-libs.x86_64 0:5.7.16-1.el7 mysql-community-libs-compat.x86_64 0:5.7.16-1.el7 mysql-community-server.x86_64 0:5.7.16-1.el7 Dependency Installed: mysql-community-common.x86_64 0:5.7.16-1.el7 Replaced: mariadb.x86_64 1:5.5.50-1.el7_2 mariadb-devel.x86_64 1:5.5.50-1.el7_2 mariadb-libs.x86_64 1:5.5.50-1.el7_2 Complete!
(7)啟動服務
sudo service mysqld start
服務器回應
[azrlnx04@azrlnx04 mysql]$ sudo service mysqld start Redirecting to /bin/systemctl start mysqld.service
(8)查看服務
sudo service mysqld status
服務器回應

[azrlnx04@azrlnx04 mysql]$ sudo service mysqld status Redirecting to /bin/systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2016-11-02 04:00:47 UTC; 16s ago Process: 2710 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 2626 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 2713 (mysqld) CGroup: /system.slice/mysqld.service └─2713 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid Nov 02 04:00:14 azrlnx04 systemd[1]: Starting MySQL Server... Nov 02 04:00:47 azrlnx04 systemd[1]: Started MySQL Server. [azrlnx04@azrlnx04 mysql]$ chkconfig --list | grep mysqld Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'.
(9)查看mysql默認口令
sudo grep 'temporary password' /var/log/mysqld.log
服務器回應,查看默認的口令就是 p2<yx2dd;jhO
[azrlnx04@azrlnx04 etc]$ sudo grep 'temporary password' /var/log/mysqld.log [sudo] password for azrlnx04: 2016-11-02T04:00:28.749910Z 1 [Note] A temporary password is generated for root@localhost: p2<yx2dd;jhO [azrlnx04@azrlnx04 etc]$
(10)使用root嘗試登陸mysql,使用默認的口令
mysql -u root -p
服務器回應

[azrlnx04@azrlnx04 etc]$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 5.7.16 Copyright (c) 2000, 2016, 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>
(11)修改口令
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
服務器回應,口令不符合需要,第二次修改成功
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Pro@#13'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword'; Query OK, 0 rows affected (0.00 sec)
(12)使用命令查看所有DB
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
(13)其他可用的包
sudo yum --disablerepo=\* --enablerepo='mysql*-community*' list available
服務器回應

[azrlnx04@azrlnx04 etc]$ sudo yum --disablerepo=\* --enablerepo='mysql*-community*' list available [sudo] password for azrlnx04: Loaded plugins: fastestmirror, langpacks mysql-connectors-community-source | 2.4 kB 00:00:00 mysql-tools-community-source | 2.4 kB 00:00:00 mysql55-community | 2.5 kB 00:00:00 mysql55-community-source | 2.4 kB 00:00:00 mysql56-community | 2.5 kB 00:00:00 mysql56-community-source | 2.4 kB 00:00:00 mysql57-community-source | 2.4 kB 00:00:00 mysql80-community | 2.5 kB 00:00:00 mysql80-community-source | 2.4 kB 00:00:00 (1/9): mysql55-community/x86_64/primary_db | 131 kB 00:00:00 (2/9): mysql56-community/x86_64/primary_db | 152 kB 00:00:00 (3/9): mysql-connectors-community-source/primary_db | 5.3 kB 00:00:00 (4/9): mysql55-community-source/primary_db | 7.9 kB 00:00:00 (5/9): mysql-tools-community-source/primary_db | 7.8 kB 00:00:01 (6/9): mysql57-community-source/primary_db | 5.0 kB 00:00:00 (7/9): mysql56-community-source/primary_db | 8.1 kB 00:00:00 (8/9): mysql80-community-source/primary_db | 2.4 kB 00:00:00 (9/9): mysql80-community/x86_64/primary_db | 17 kB 00:00:00 Loading mirror speeds from cached hostfile Available Packages mysql-community-bench.x86_64 5.6.34-2.el7 mysql56-community mysql-community-client.i686 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-client.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-common.i686 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-common.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-devel.i686 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-devel.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-embedded.i686 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-embedded.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-embedded-compat.i686 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-embedded-compat.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-embedded-devel.i686 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-embedded-devel.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-libs.i686 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-libs.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-libs-compat.i686 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-libs-compat.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-release.noarch el7-7 mysql57-community mysql-community-server.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-community-test.x86_64 8.0.0-0.1.dmr.el7 mysql80-community mysql-connector-odbc.x86_64 5.3.6-1.el7 mysql-connectors-community mysql-connector-odbc-debuginfo.x86_64 5.3.6-1.el7 mysql-connectors-community mysql-connector-odbc-setup.x86_64 5.3.6-1.el7 mysql-connectors-community mysql-connector-python.noarch 2.0.4-1.el7 mysql-connectors-community mysql-connector-python.x86_64 2.1.4-1.el7 mysql-connectors-community mysql-connector-python-cext.x86_64 2.1.4-1.el7 mysql-connectors-community mysql-connector-python-debuginfo.x86_64 2.1.4-1.el7 mysql-connectors-community mysql-router.x86_64 2.0.3-1.el7 mysql-tools-community mysql-router-debuginfo.x86_64 2.0.3-1.el7 mysql-tools-community mysql-utilities.noarch 1.6.4-1.el7 mysql-tools-community mysql-utilities-extra.noarch 1.5.6-1.el7 mysql-tools-community mysql-workbench-community.x86_64 6.3.8-1.el7 mysql-tools-community mysql-workbench-community-debuginfo.x86_64 6.3.8-1.el7 mysql-tools-community [azrlnx04@azrlnx04 etc]$
(14)關於其他包的安裝,需要等后續使用后才能確定
三:安裝sonarQube
(0)登陸mysql運行腳本
[azrlnx04@azrlnx04 etc]$ mysql -uroot -p
Enter password:
mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; mysql> CREATE USER 'sonar' IDENTIFIED BY 'sonar'; mysql> GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar'; mysql> GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar'; mysql> FLUSH PRIVILEGES;
運行創建用戶,一定要記得嘗試使用新創建的用戶登陸至mysql
服務器回應

[azrlnx04@azrlnx04 etc]$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 13 Server version: 5.7.16 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; Query OK, 1 row affected (0.01 sec) mysql> CREATE USER 'sonar' IDENTIFIED BY 'sonar'; ERROR 1819 (HY000): Your password does not satisfy the current policy requiremen ts mysql> GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar'; ERROR 1819 (HY000): Your password does not satisfy the current policy requiremen ts mysql> GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar'; ERROR 1819 (HY000): Your password does not satisfy the current policy requiremen ts mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> show databases -> ; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sonar | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql>
至此,mysql會新建一個數據庫sonar,以上的腳本會創建一個數據庫及用戶名sonar,並將用戶sonar應用至sonar數據庫
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sonar |
| sys |
+--------------------+
5 rows in set (0.00 sec)
(1)將下載好的sonarqube-6.1.zip和sonar-scanner-2.8.zip通過WinSCP復制至服務器/sonar/中,或者使用命令下載文件
wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.1.zip wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.8.zip
(2)分別進入兩個文件夾,對文件增加權限
chmod 777 sonarqube-6.1.zip chmod 777 sonar-scanner-2.8.zip
服務器回應

[azrlnx04@azrlnx04 etc]$ cd /home/azrlnx04 [azrlnx04@azrlnx04 ~]$ ls -l total 0 drwxrwxr-x. 2 azrlnx04 azrlnx04 36 Nov 2 08:41 java drwxrwxr-x. 2 azrlnx04 azrlnx04 55 Nov 2 13:39 mysql drwxrwxr-x. 2 azrlnx04 azrlnx04 58 Nov 2 16:33 sonar [azrlnx04@azrlnx04 ~]$ cd sonar [azrlnx04@azrlnx04 sonar]$ ls -l total 125076 -rw-rw-r--. 1 azrlnx04 azrlnx04 127575358 Oct 24 11:09 sonarqube-6.1.zip -rw-rw-r--. 1 azrlnx04 azrlnx04 496533 Oct 24 14:09 sonar-scanner-2.8.zip [azrlnx04@azrlnx04 sonar]$ chmod 777 sonarqube-6.1.zip [azrlnx04@azrlnx04 sonar]$ chmod 777 sonar-scanner-2.8.zip [azrlnx04@azrlnx04 sonar]$ ls -l total 125076 -rwxrwxrwx. 1 azrlnx04 azrlnx04 127575358 Oct 24 11:09 sonarqube-6.1.zip -rwxrwxrwx. 1 azrlnx04 azrlnx04 496533 Oct 24 14:09 sonar-scanner-2.8.zip
(3)解壓zip文件
(3.1)進入/sonar中,使用命令解壓sonarqube-6.1.zip
unzip sonarqube-6.1.zip
服務器回應太長,這里不給出了
(3.2)進入/sonar中,解壓sonar-scanner-2.8.zip
unzip sonar-scanner-2.8.zip
服務器回應是很少的,因為壓縮文件比較小
(4)進入至/sonar/sonarqube-6.1/conf中,使用vi命令打開sonar.properties
vi sonar.properties
並修改其中的三個節點,修改的方式只需要將行內容最前的#號刪除即可
在這里特別提醒一下,原本在Windows系統中,是可以建立口令為sonar的sonar用戶的,但在Linux中,其實,當在mysql中創建口令為sonar的用戶時,會發生錯誤,但我並未在意,一直以為系統需要其他的配置
建議是,創建用戶后, 使用用戶登陸一下mysql看一下是否能夠正常登陸,不然在運行sonar時,肯定不會成功,且你很難反應是mysql口令的原因。
sonar.jdbc.username= sonar.jdbc.password= sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
(5)打開文件夾
[azrlnx04@azrlnx04 sonar]$ cd sonarqube-6.1/bin/linux-x86-64/
[azrlnx04@azrlnx04 linux-x86-64]$ ls -l
服務器回應
[azrlnx04@azrlnx04 sonar]$ cd sonarqube-6.1/bin/linux-x86-64/ [azrlnx04@azrlnx04 linux-x86-64]$ ls -l total 128 drwxr-xr-x. 2 azrlnx04 azrlnx04 26 Dec 9 2010 lib -rwxr-xr-x. 1 azrlnx04 azrlnx04 15521 Oct 11 09:02 sonar.sh -rwxr-xr-x. 1 azrlnx04 azrlnx04 111027 Dec 9 2010 wrapper
(6)運行命令,我們這里是使用啟動服務,使用 sonar.sh start
sonar.sh start 啟動服務
sonar.sh stop 停止服務
sonar.sh restart 重啟服務
[azrlnx04@azrlnx04 linux-x86-64]$ sonar.sh start
-bash: sonar.sh: command not found
當出現了命令無法找到的情況,需要將sonar的目錄加入至環境變量
查看環境變量,並加入新的地址,參考地址:http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path
[azrlnx04@azrlnx04 ~]$ $PATH
-bash: /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/azrlnx04/.local/bin:/home/azrlnx04/bin: No such file or directory
[azrlnx04@azrlnx04 ~]$ PATH=$PATH:~/sonar/sonarqube-6.1/bin/linux-x86-64/
加入SONAR_HOME和SONAR_RUNNER_HOME兩個變量,和處理jdk的路徑一樣,並將新加的變量都加入至變量PATH中(PATH變量是整個系統用戶都可以用到),在當前用戶的目錄打開.bash_profile文件,將變量內容加入至文件中
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH export JAVA_HOME=/usr/bin/java export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=./$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
修改后,加入顏色部分即加入的內容
# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH export JAVA_HOME=/usr/bin/java export SONAR_HOME=~/sonar/sonarqube-6.1/bin/linux-x86-64/ export SONAR_RUNNER_HOME=~/sonar/sonar-scanner-2.8/bin/ export PATH=$JAVA_HOME/bin:$SONAR_HOME:$SONAR_RUNNER_HOME:$PATH export CLASSPATH=./$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
再次運行命令 sonar.sh start
服務器回應是非常簡單的,告訴你SonarQube已經啟動了
[azrlnx04@azrlnx04 ~]$ sonar.sh start
Starting SonarQube...
Started SonarQube.
與Windows不同,Windows命令窗口中會出現所有的信息,但Linux會將運行的信息都存放至sonar文件夾中的logs子文件夾,可以在其中查看sonar.log文件(有時文件太大,則會分成幾個文件,文件名與日期對應),開始我一直以為不成功,其實后台有一部分的信息已經保存下來了
2016.11.07 09:10:07 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /home/azrlnx04/sonar/sonarqube-6.1/temp 2016.11.07 09:10:07 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[es]: /usr/java/jdk1.8.0_111/jre/bin/java -Djava.awt.headless=true -Xmx1G -Xms256m -Xss256k -Djna.nosys=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/home/azrlnx04/sonar/sonarqube-6.1/temp -javaagent:/usr/java/jdk1.8.0_111/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/search/* org.sonar.search.SearchServer /home/azrlnx04/sonar/sonarqube-6.1/temp/sq-process4628608208409917744properties 2016.11.07 09:10:08 INFO es[][o.s.p.ProcessEntryPoint] Starting es 2016.11.07 09:10:08 INFO es[][o.s.s.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2016.11.07 09:10:09 INFO es[][o.elasticsearch.node] [sonarqube] version[2.3.3], pid[30725], build[218bdf1/2016-05-17T15:40:04Z] 2016.11.07 09:10:09 INFO es[][o.elasticsearch.node] [sonarqube] initializing ... 2016.11.07 09:10:09 INFO es[][o.e.plugins] [sonarqube] modules [], plugins [], sites [] 2016.11.07 09:10:09 INFO es[][o.elasticsearch.env] [sonarqube] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [25.8gb], net total_space [29.9gb], spins? [unknown], types [rootfs] 2016.11.07 09:10:09 INFO es[][o.elasticsearch.env] [sonarqube] heap size [1007.3mb], compressed ordinary object pointers [true] 2016.11.07 09:10:09 WARN es[][o.elasticsearch.env] [sonarqube] max file descriptors [4096] for elasticsearch process likely too low, consider increasing to at least [65536] 2016.11.07 09:10:13 INFO es[][o.elasticsearch.node] [sonarqube] initialized 2016.11.07 09:10:13 INFO es[][o.elasticsearch.node] [sonarqube] starting ... 2016.11.07 09:10:13 INFO es[][o.e.transport] [sonarqube] publish_address {127.0.0.1:9001}, bound_addresses {127.0.0.1:9001} 2016.11.07 09:10:13 INFO es[][o.e.discovery] [sonarqube] sonarqube/VxJMhq7YTSe99uUNYRL81w 2016.11.07 09:10:16 INFO es[][o.e.cluster.service] [sonarqube] new_master {sonarqube}{VxJMhq7YTSe99uUNYRL81w}{127.0.0.1}{127.0.0.1:9001}{rack_id=sonarqube, master=true}, reason: zen-disco-join(elected_as_master, [0] joins received) 2016.11.07 09:10:16 INFO es[][o.elasticsearch.node] [sonarqube] started 2016.11.07 09:10:16 INFO es[][o.e.gateway] [sonarqube] recovered [5] indices into cluster_state 2016.11.07 09:10:19 INFO es[][o.e.c.r.allocation] [sonarqube] Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[tests][0], [tests][0]] ...]). 2016.11.07 09:10:19 INFO app[][o.s.p.m.Monitor] Process[es] is up 2016.11.07 09:10:19 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[web]: /usr/java/jdk1.8.0_111/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false -Djruby.compile.invokedynamic=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/home/azrlnx04/sonar/sonarqube-6.1/temp -javaagent:/usr/java/jdk1.8.0_111/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/server/*:/home/azrlnx04/sonar/sonarqube-6.1/lib/jdbc/mysql/mysql-connector-java-5.1.39.jar org.sonar.server.app.WebServer /home/azrlnx04/sonar/sonarqube-6.1/temp/sq-process8650920502670994045properties 2016.11.07 09:10:20 INFO web[][o.s.p.ProcessEntryPoint] Starting web 2016.11.07 09:10:21 INFO web[][o.s.s.a.TomcatContexts] Webapp directory: /home/azrlnx04/sonar/sonarqube-6.1/web 2016.11.07 09:10:21 INFO web[][o.a.c.h.Http11NioProtocol] Initializing ProtocolHandler ["http-nio-127.0.0.1-9000"] 2016.11.07 09:10:21 INFO web[][o.a.t.u.n.NioSelectorPool] Using a shared selector for servlet write/read 2016.11.07 09:10:22 INFO web[][o.e.plugins] [Jennifer Kale] modules [], plugins [], sites [] 2016.11.07 09:10:24 INFO web[][o.s.s.e.EsClientProvider] Connected to local Elasticsearch: [127.0.0.1:9001] 2016.11.07 09:10:24 INFO web[][o.s.s.p.LogServerVersion] SonarQube Server / 6.1 / dc148a71a1c184ccad588b66251980c994879dff 2016.11.07 09:10:24 INFO web[][o.sonar.db.Database] Create JDBC data source for jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&autoReconnect=true&useSSL=false
使用命令可以在本機打開網站
curl http://localhost:9000
只要能夠看到網頁的HTML代碼,則是成功的,如果有查看我之前的文章,在Windows中安裝sonar的話,此刻應該可以通過瀏覽器打開http://localhost:9000了,但Linux不同,即使內部能夠訪問,但還需要將防火牆中打開某個端口才可以在服務器外部進行訪問
(7)配置firewalld
先使用root用戶

以下部分是Linux管理員給出的命令行 How to enable root access on Microsoft Azure Cloud. 1. Login via ssh using your sudo user 2. Now login as root user Code: [Select] sudo su - 3. check if root access is set (LOCK means that root access is disabled) Code: [Select] [root@Linux ~]# grep root /etc/shadow root:*LOCK*:14600:::::: 4. enable root access (as root user enter command passwd) Code: [Select] [root@Linux ~]# passwd now enter your password and root access is enabled, you can check this by using command "grep root /etc/shadow"
先查看firewalld狀態,使用系統查看,或是直接firewall-cmd 命令查看
[root@azrlnx04 ~]# systemctl status firewalld
[root@azrlnx04 ~]# firewall-cmd --state
FirewallD is not running
如未運行,則需要先讓它運行,關於如何開始firewalld,參考:https://www.liquidweb.com/kb/how-to-start-and-enable-firewalld-on-centos-7/
關於詳細的firewalld信息,參考:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html
[root@azrlnx04 ~]# systemctl start firewalld [root@azrlnx04 ~]# firewall-cmd --state running
另外關於增加端口的文章,參考:http://stackoverflow.com/questions/24729024/centos-7-open-firewall-port
[root@azrlnx04 ~]# firewall-cmd --zone=public --add-port=9000/tcp --permanent success [root@azrlnx04 ~]# firewall-cmd --zone=dmz --add-port=9000/tcp --permanent success
[root@azrlnx04 ~]# firewall-cmd --reload
success
以上都沒步驟(7)都有運行,但沒有效果,運行步驟(8)才最終可用,現在還不能確定步驟(7)是否是多余的。
(8)如果配置的時候,查看現有的配置,當時sonarQube中設置的肯定只是監聽到127.0.0.1的9000端口,而我們需要讓它開放出來就可以
[root@azrlnx04 ~]# netstat -tpln | grep 9000
tcp6 0 0 :::9000 :::* LISTEN 38927/java
在sonarQube的配置文件(sonarQube6.1/conf/sonar.properties)中,節點
# Binding IP address. For servers with more than one IP address, this property specifies which # address will be used for listening on the specified ports. # By default, ports will be used on all IP addresses associated with the server. sonar.web.host=127.0.0.1
修改為,意思為,之前監聽的是127.0.0.1的端口,現在可以監聽所有的
# Binding IP address. For servers with more than one IP address, this property specifies which # address will be used for listening on the specified ports. # By default, ports will be used on all IP addresses associated with the server. sonar.web.host=*
最終才可用
寫在最后,至此,Linux服務器上的sonarQube Server端已經完整安裝了,但關於Scan代碼的問題上,有一個很關鍵的問題就是,無法在Linux服務器中Scan C#的源代碼。
https://groups.google.com/forum/#!topic/sonarqube/Ep_BgEF2pR0
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2017-01-19更新
今天看到關於C#/Java/JavaScript的插件有新版本可以更新,所以就想將最新的插件安裝至sonarQube系統中,但卻發現更新插件后重啟服務器時等了很久都不見完成,並且在等待了20分鍾后再次刷新,發現sonarQube的站點無法訪問了,這可點方了,因為這個是正式環境的服務器,如果不能使用將帶來很大的影響,方是方,但還得解決問題不是?
下圖是我打開插件中心發現的更新插件,解決問題后我只更新了C#插件,另外兩個都沒有進行更新。出現問題的就是Java插件(4.4)
下圖就是使用Chrome瀏覽器刷新后無法訪問的圖片
我首先想到的是sonarQube出現了問題,其次是Linux防火牆出現了問題,
1.我先查看了sonarQube的日志
/sonarqube6.1/logs/sonar.log,出現問題時一般先查看該日志文件
嘗試重啟sonarQube服務器
[azrlnx04@azrlnx04 linux-x86-64]$ sonar.sh start Starting SonarQube... Started SonarQube. [azrlnx04@azrlnx04 linux-x86-64]$ sonar.sh stop Stopping SonarQube... SonarQube was not running. [azrlnx04@azrlnx04 linux-x86-64]$ sonar.sh start Starting SonarQube... Started SonarQube. [azrlnx04@azrlnx04 linux-x86-64]$ sonar.sh status SonarQube is not running. [azrlnx04@azrlnx04 linux-x86-64]$ sonar.sh start -uroot -p Starting SonarQube... Started SonarQube. [azrlnx04@azrlnx04 linux-x86-64]$ curl http://localhost:9000 curl: (7) Failed connect to localhost:9000; Connection refused
看起來似乎服務可以起來,但是在Linux服務器上訪問卻不成功,這個時候我卻以為sonarQube是沒有問題的,繼續想着查看是否是防火牆出現了問題
2.其次查看了Linux防火牆
[azrlnx04@azrlnx04 linux-x86-64]$ curl http://localhost:9000 curl: (7) Failed connect to localhost:9000; Connection refused [azrlnx04@azrlnx04 linux-x86-64]$ curl http://localhost:9000 curl: (7) Failed connect to localhost:9000; Connection refused
[root@azrlnx04 ~]# netstat -tpln | grep 9000 tcp6 0 0 :::9000 :::* LISTEN 50177/java [root@azrlnx04 ~]# curl http://localhost:9000
在重啟了sonarQube服務一會兒是在正常監聽9000端口的,但過一會兒又不行了,這應該問題還是出現在sonarQube,查看日志

2017.01.19 07:36:18 INFO ce[AVmz8ClrQiyNdwo6POOW][o.s.s.c.t.CeWorkerCallableImpl] Execute task | project=Instantnoodle.Workbench | type=REPORT | id=AVmz8ClrQiyNdwo6POOW | submitter=admin 2017.01.19 07:37:30 INFO ce[AVmz8ClrQiyNdwo6POOW][o.s.s.c.t.CeWorkerCallableImpl] Executed task | project=Instantnoodle.Workbench | type=REPORT | id=AVmz8ClrQiyNdwo6POOW | submitter=admin | time=71933ms 2017.01.19 09:11:07 ERROR web[][o.s.s.w.WebServiceEngine] Fail to process request http://10.10.5.9:9000/api/plugins/update org.sonar.api.utils.SonarException: Fail to download the plugin (java, version 4.4) from https://sonarsource.bintray.com/Distribution/sonar-java-plugin/sonar-java-plugin-4.4.0.8066.jar (error is : Source '/home/azrlnx04/sonar/sonarqube-6.1/extensions/downloads/sonar-java-plugin-4.4.0.8066.jar.tmp' does not exist) at org.sonar.server.plugins.PluginDownloader.download(PluginDownloader.java:138) ~[sonar-server-6.1.jar:na] at org.sonar.server.plugins.ws.UpdateAction.handle(UpdateAction.java:79) ~[sonar-server-6.1.jar:na] at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:109) ~[sonar-server-6.1.jar:na] at org.sonar.server.ws.WebServiceFilter.doFilter(WebServiceFilter.java:74) [sonar-server-6.1.jar:na] at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:126) [sonar-server-6.1.jar:na] at org.sonar.server.platform.web.MasterServletFilter.doFilter(MasterServletFilter.java:95) [sonar-server-6.1.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:60) [sonar-server-6.1.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.sonar.server.platform.web.RoutesFilter.doFilter(RoutesFilter.java:55) [sonar-server-6.1.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.sonar.server.platform.web.RootFilter.doFilter(RootFilter.java:113) [sonar-server-6.1.jar:na] at org.sonar.server.platform.web.RootFilter.doFilter(RootFilter.java:81) [sonar-server-6.1.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.32.jar:8.0.32] at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:191) [logback-access-1.1.3.jar:na] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.32.jar:8.0.32] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.32.jar:8.0.32] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111] Caused by: java.io.FileNotFoundException: Source '/home/azrlnx04/sonar/sonarqube-6.1/extensions/downloads/sonar-java-plugin-4.4.0.8066.jar.tmp' does not exist at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1074) ~[commons-io-2.4.jar:2.4] at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1038) ~[commons-io-2.4.jar:2.4] at org.sonar.server.plugins.PluginDownloader.downloadRelease(PluginDownloader.java:160) ~[sonar-server-6.1.jar:na] at org.sonar.server.plugins.PluginDownloader.download(PluginDownloader.java:133) ~[sonar-server-6.1.jar:na] ... 32 common frames omitted 2017.01.19 09:11:20 INFO web[][o.s.s.p.w.RestartAction] SonarQube restart requested by admin 2017.01.19 09:11:20 INFO app[][o.s.p.m.Monitor] Process [web] requested restart 2017.01.19 09:11:20 INFO app[][o.s.p.m.Monitor] Process[ce] is stopping 2017.01.19 09:11:20 INFO ce[][o.s.p.StopWatcher] Stopping process 2017.01.19 09:11:20 INFO ce[][o.s.ce.app.CeServer] Compute Engine shutting down... 2017.01.19 09:11:22 INFO app[][o.s.p.m.Monitor] Process[ce] is stopped 2017.01.19 09:11:22 INFO app[][o.s.p.m.Monitor] Process[web] is stopping 2017.01.19 09:11:22 INFO web[][o.s.p.StopWatcher] Stopping process 2017.01.19 09:11:22 INFO web[][o.a.c.h.Http11NioProtocol] Pausing ProtocolHandler ["http-nio-9000"] 2017.01.19 09:11:23 INFO web[][o.s.s.n.NotificationDaemon] Notification service stopped 2017.01.19 09:11:23 WARN web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Object.wait(Native Method) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143) com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43) 2017.01.19 09:11:23 INFO web[][o.a.c.h.Http11NioProtocol] Stopping ProtocolHandler ["http-nio-9000"] 2017.01.19 09:11:25 INFO web[][o.a.c.h.Http11NioProtocol] Destroying ProtocolHandler ["http-nio-9000"] 2017.01.19 09:11:25 INFO web[][o.s.s.a.TomcatAccessLog] Web server is stopped 2017.01.19 09:11:25 INFO app[][o.s.p.m.Monitor] Process[web] is stopped 2017.01.19 09:11:25 INFO app[][o.s.p.m.Monitor] Process[es] is stopping 2017.01.19 09:11:25 INFO es[][o.s.p.StopWatcher] Stopping process 2017.01.19 09:11:25 INFO es[][o.elasticsearch.node] [sonarqube] stopping ... 2017.01.19 09:11:25 INFO es[][o.elasticsearch.node] [sonarqube] stopped 2017.01.19 09:11:25 INFO es[][o.elasticsearch.node] [sonarqube] closing ... 2017.01.19 09:11:25 INFO es[][o.elasticsearch.node] [sonarqube] closed 2017.01.19 09:11:26 INFO app[][o.s.p.m.Monitor] Process[es] is stopped 2017.01.19 09:11:26 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /home/azrlnx04/sonar/sonarqube-6.1/temp 2017.01.19 09:11:26 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[es]: /usr/java/jdk1.8.0_111/jre/bin/java -Djava.awt.headless=true -Xmx1G -Xms256m -Xss256k -Djna.nosys=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/home/azrlnx04/sonar/sonarqube-6.1/temp -javaagent:/usr/java/jdk1.8.0_111/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/search/* org.sonar.search.SearchServer /home/azrlnx04/sonar/sonarqube-6.1/temp/sq-process200122875469733762properties 2017.01.19 09:11:28 INFO es[][o.s.p.ProcessEntryPoint] Starting es 2017.01.19 09:11:28 INFO es[][o.s.s.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2017.01.19 09:11:28 INFO es[][o.elasticsearch.node] [sonarqube] version[2.3.3], pid[46460], build[218bdf1/2016-05-17T15:40:04Z] 2017.01.19 09:11:28 INFO es[][o.elasticsearch.node] [sonarqube] initializing ... 2017.01.19 09:11:28 INFO es[][o.e.plugins] [sonarqube] modules [], plugins [], sites [] 2017.01.19 09:11:28 INFO es[][o.elasticsearch.env] [sonarqube] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [25.5gb], net total_space [29.9gb], spins? [unknown], types [rootfs] 2017.01.19 09:11:28 INFO es[][o.elasticsearch.env] [sonarqube] heap size [1007.3mb], compressed ordinary object pointers [true] 2017.01.19 09:11:28 WARN es[][o.elasticsearch.env] [sonarqube] max file descriptors [4096] for elasticsearch process likely too low, consider increasing to at least [65536] 2017.01.19 09:11:32 INFO es[][o.elasticsearch.node] [sonarqube] initialized 2017.01.19 09:11:32 INFO es[][o.elasticsearch.node] [sonarqube] starting ... 2017.01.19 09:11:32 INFO es[][o.e.transport] [sonarqube] publish_address {127.0.0.1:9001}, bound_addresses {127.0.0.1:9001} 2017.01.19 09:11:32 INFO es[][o.e.discovery] [sonarqube] sonarqube/a7_9U6plQ-OP56_1wxxEvA 2017.01.19 09:11:36 INFO es[][o.e.cluster.service] [sonarqube] new_master {sonarqube}{a7_9U6plQ-OP56_1wxxEvA}{127.0.0.1}{127.0.0.1:9001}{rack_id=sonarqube, master=true}, reason: zen-disco-join(elected_as_master, [0] joins received) 2017.01.19 09:11:36 INFO es[][o.elasticsearch.node] [sonarqube] started 2017.01.19 09:11:36 INFO es[][o.e.gateway] [sonarqube] recovered [5] indices into cluster_state 2017.01.19 09:11:38 INFO es[][o.e.c.r.allocation] [sonarqube] Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[rules][0], [tests][4], [tests][4], [rules][0]] ...]). 2017.01.19 09:11:39 INFO app[][o.s.p.m.Monitor] Process[es] is up 2017.01.19 09:11:39 INFO app[][o.s.p.m.JavaProcessLauncher] Launch process[web]: /usr/java/jdk1.8.0_111/jre/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false -Djruby.compile.invokedynamic=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/home/azrlnx04/sonar/sonarqube-6.1/temp -javaagent:/usr/java/jdk1.8.0_111/jre/lib/management-agent.jar -cp ./lib/common/*:./lib/server/*:/home/azrlnx04/sonar/sonarqube-6.1/lib/jdbc/mysql/mysql-connector-java-5.1.39.jar org.sonar.server.app.WebServer /home/azrlnx04/sonar/sonarqube-6.1/temp/sq-process8182427158650393272properties 2017.01.19 09:11:40 INFO web[][o.s.p.ProcessEntryPoint] Starting web 2017.01.19 09:11:41 INFO web[][o.s.s.a.TomcatContexts] Webapp directory: /home/azrlnx04/sonar/sonarqube-6.1/web 2017.01.19 09:11:42 INFO web[][o.a.c.h.Http11NioProtocol] Initializing ProtocolHandler ["http-nio-9000"] 2017.01.19 09:11:42 INFO web[][o.a.t.u.n.NioSelectorPool] Using a shared selector for servlet write/read 2017.01.19 09:11:43 INFO web[][o.e.plugins] [Serpentina] modules [], plugins [], sites [] 2017.01.19 09:11:44 INFO web[][o.s.s.e.EsClientProvider] Connected to local Elasticsearch: [127.0.0.1:9001] 2017.01.19 09:11:44 INFO web[][o.s.s.p.LogServerVersion] SonarQube Server / 6.1 / dc148a71a1c184ccad588b66251980c994879dff 2017.01.19 09:11:44 INFO web[][o.sonar.db.Database] Create JDBC data source for jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&autoReconnect=true&useSSL=false 2017.01.19 09:11:47 INFO web[][o.s.s.p.ServerFileSystemImpl] SonarQube home: /home/azrlnx04/sonar/sonarqube-6.1 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Plugin JavaScript [javascript] updated to version 2.19.0.3866 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Plugin Java [java] updated to version 4.4.0.8066 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Plugin C# [csharp] updated to version 5.5.2.537 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Plugin CSS / Less [css] updated to version 2.4 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin C# / 5.5.2.537 / a4f663cf02cdcc88c221aaae7e7156fa4d176c07 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin CSS / Less / 2.4 / 5ac876d69f61a2c5fce597f3243bae45b8cd8f5f 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin Findbugs / 3.4.3 / 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin FxCop / 1.0 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin Git / 1.2 / a713dd64daf8719ba4e7f551f9a1966c62690c17 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin GitHub / 1.3 / a329b577298d259741a3098a80651a59fa180a2e 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin Java / 4.4.0.8066 / 2703cce280bb210cffe8f8ac918df5f2c4d770f2 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin JavaScript / 2.19.0.3866 / 97832288f366dae27584956414242e18dc96bca3 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin SVN / 1.3 / aff503d48bc77b07c2b62abf93249d0a20bd355c 2017.01.19 09:11:48 INFO web[][o.s.s.p.ServerPluginRepository] Deploy plugin TFVC / 2.1.2 / 93aaaec5d7246e257dc6d7ebb6b66f5e2ece2a83 2017.01.19 09:11:49 ERROR web[][o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.web.PlatformServletContextListener java.lang.IllegalStateException: Fail to unzip plugin [java] /home/azrlnx04/sonar/sonarqube-6.1/extensions/plugins/sonar-java-plugin-4.4.0.8066.jar to /home/azrlnx04/sonar/sonarqube-6.1/data/web/deploy/plugins/java at org.sonar.server.plugins.ServerPluginJarExploder.explode(ServerPluginJarExploder.java:62) ~[sonar-server-6.1.jar:na] at org.sonar.core.platform.PluginLoader.defineClassloaders(PluginLoader.java:91) ~[sonar-core-6.1.jar:na] at org.sonar.core.platform.PluginLoader.load(PluginLoader.java:71) ~[sonar-core-6.1.jar:na] at org.sonar.server.plugins.ServerPluginRepository.loadInstances(ServerPluginRepository.java:288) ~[sonar-server-6.1.jar:na] at org.sonar.server.plugins.ServerPluginRepository.start(ServerPluginRepository.java:117) ~[sonar-server-6.1.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111] at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110) ~[picocontainer-2.15.jar:na] at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89) ~[picocontainer-2.15.jar:na] at org.sonar.core.platform.ComponentContainer$1.start(ComponentContainer.java:320) ~[sonar-core-6.1.jar:na] at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84) ~[picocontainer-2.15.jar:na] at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169) ~[picocontainer-2.15.jar:na] at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132) ~[picocontainer-2.15.jar:na] at org.picocontainer.behaviors.Stored.start(Stored.java:110) ~[picocontainer-2.15.jar:na] at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016) ~[picocontainer-2.15.jar:na] at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009) ~[picocontainer-2.15.jar:na] at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767) ~[picocontainer-2.15.jar:na] at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:141) ~[sonar-core-6.1.jar:na] at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:88) ~[sonar-server-6.1.jar:na] at org.sonar.server.platform.Platform.start(Platform.java:216) ~[sonar-server-6.1.jar:na] at org.sonar.server.platform.Platform.startLevel2Container(Platform.java:182) ~[sonar-server-6.1.jar:na] at org.sonar.server.platform.Platform.init(Platform.java:91) ~[sonar-server-6.1.jar:na] at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:44) ~[sonar-server-6.1.jar:na] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [tomcat-embed-core-8.0.32.jar:8.0.32] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [tomcat-embed-core-8.0.32.jar:8.0.32] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111] Caused by: java.io.EOFException: Unexpected end of ZLIB input stream at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:417) ~[na:1.8.0_111] at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) ~[na:1.8.0_111] at java.io.FilterInputStream.read(FilterInputStream.java:107) ~[na:1.8.0_111] at org.sonar.api.internal.apachecommons.io.IOUtils.copyLarge(IOUtils.java:1792) ~[sonar-plugin-api-6.1.jar:na] at org.sonar.api.internal.apachecommons.io.IOUtils.copyLarge(IOUtils.java:1769) ~[sonar-plugin-api-6.1.jar:na] at org.sonar.api.internal.apachecommons.io.IOUtils.copy(IOUtils.java:1744) ~[sonar-plugin-api-6.1.jar:na] at org.sonar.api.utils.ZipUtils.copy(ZipUtils.java:147) ~[sonar-plugin-api-6.1.jar:na] at org.sonar.api.utils.ZipUtils.unzip(ZipUtils.java:121) ~[sonar-plugin-api-6.1.jar:na] at org.sonar.server.plugins.ServerPluginJarExploder.explode(ServerPluginJarExploder.java:59) ~[sonar-server-6.1.jar:na] ... 33 common frames omitted 2017.01.19 09:11:49 ERROR web[][o.a.c.c.StandardContext] One or more listeners failed to start. Full details will be found in the appropriate container log file 2017.01.19 09:11:49 ERROR web[][o.a.c.c.StandardContext] Context [] startup failed due to previous errors 2017.01.19 09:11:49 WARN web[][o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Object.wait(Native Method) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143) com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43) 2017.01.19 09:11:49 INFO web[][o.a.c.h.Http11NioProtocol] Starting ProtocolHandler ["http-nio-9000"] 2017.01.19 09:11:49 INFO web[][o.s.s.a.TomcatAccessLog] Web server is started 2017.01.19 09:11:49 INFO web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000 2017.01.19 09:11:49 WARN web[][o.s.p.ProcessEntryPoint] Fail to start web java.lang.IllegalStateException: Webapp did not start at org.sonar.server.app.EmbeddedTomcat.isUp(EmbeddedTomcat.java:84) ~[sonar-server-6.1.jar:na] at org.sonar.server.app.WebServer.isUp(WebServer.java:46) [sonar-server-6.1.jar:na] at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:105) ~[sonar-process-6.1.jar:na] at org.sonar.server.app.WebServer.main(WebServer.java:67) [sonar-server-6.1.jar:na] 2017.01.19 09:11:49 INFO web[][o.a.c.h.Http11NioProtocol] Pausing ProtocolHandler ["http-nio-9000"] 2017.01.19 09:11:50 INFO web[][o.a.c.h.Http11NioProtocol] Stopping ProtocolHandler ["http-nio-9000"] 2017.01.19 09:11:50 INFO web[][o.a.c.h.Http11NioProtocol] Destroying ProtocolHandler ["http-nio-9000"] 2017.01.19 09:11:50 INFO web[][o.s.s.a.TomcatAccessLog] Web server is stopped 2017.01.19 09:11:50 INFO app[][o.s.p.m.Monitor] Process[es] is stopping 2017.01.19 09:11:51 INFO es[][o.s.p.StopWatcher] Stopping process 2017.01.19 09:11:51 INFO es[][o.elasticsearch.node] [sonarqube] stopping ... 2017.01.19 09:11:51 INFO es[][o.elasticsearch.node] [sonarqube] stopped 2017.01.19 09:11:51 INFO es[][o.elasticsearch.node] [sonarqube] closing ... 2017.01.19 09:11:51 INFO es[][o.elasticsearch.node] [sonarqube] closed 2017.01.19 09:11:51 INFO app[][o.s.p.m.Monitor] Process[es] is stopped <-- Wrapper Stopped --> Wrapper Started as Daemon Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.
問題出在其中的Java插件,原因可能是沒有下載完成Java插件,導致解壓失敗,從而導致整個sonarQube啟動失敗。
嘗試辦法1:將Java插件先改名,再重新啟動sonarQube
結果1:sonarQube還是認到原有下載未完成的Java插件,無法解決該問題
嘗試辦法2:將Java插件完全刪除,再重新啟動sonarQube
結果2:sonarQube沒有插件還是無法啟動sonarQube,啟動幾秒后服務還是會死掉
嘗試辦法3:從windows系統下載Java插件最新版本,並復制至Linux機器上,再重新啟動sonarQube
未知結果3:因為在復制插件文件的過程中,老是會中斷,導致文件復制老是失敗,就放棄了該方法
嘗試辦法4:將原sonarQube文件改名,並將原sonarQube壓縮包重新解壓縮生成sonarQube文件夾,只是將原有的配置文件替換新的配置文件
結果4:因為新的sonarQube是使用原來的文件夾名稱,原來已經進行過相應的配置,確實能夠解決該問題,但不是最好的方法,個人認為比較好的方法就是使用辦法3
結論:當插件更新時發生了錯誤,應該與Linux機器沒有太大關系,需要的是及時查看日志文件,查看錯誤