服务器系统: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机器没有太大关系,需要的是及时查看日志文件,查看错误