As we all know, sonar is used for quality testing of code, and supports multiple languages, a lot of places to see before writing to build sonar, you should feel very good set up, and then try to build it myself yesterday, found himself really It is think too simple, some pit, or write to let everyone see, do not fall into the go.
Preparation: Download sonar: https://www.sonarqube.org/downloads/ I downloaded version 6.7.7 of the beginning I got the latest version 8.0, but has been given: mysql.driver the error, then I still use a stable version.
My environment: ubuntu (centos have been looking for, but Mr. Ali bought a cloud machine, or ubuntu, so I will use it, if you are centos, remember to install the command to modify it)
1. Install mysql, installed after using mysql -V (V caps) to check the version as follows:
After installing mysql, create sonar users in the database: as follows:
MySQL> the CREATE the USER 'SONAR' @ '%' IDENTIFIED BY 'sonar123';
MySQL> the CREATE DATABASE SONAR CHARACTER the SET UTF8;
. MySQL> GRANT ALL PRIVILEGES ON SONAR * the TO 'SONAR' @ '%';
above the main thing to do is : sonar to create a database and user database, and for authorization
mysql version to be equal to 5.6 or 5.6, or it can not start sonar
2. Create a folder in the softs opt directory, download sonar zip uncompress it to the directory.
unzip sonarqube-6.7.7.zip
/Opt/softs/sonarqube-6.7.7/conf/sonar.properties then modify the file, now I only configured for a moment a few:
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar123
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.web.host=0.0.0.0
sonar.web.context=
sonar.web.context=
3. Use a user starts sonar sonar, otherwise it will report the wrong es (focus: because of security issues elasticsearch not to run directly by the root user)
adduser sonartest # Create a sonar users
passwd 123456 # Create a sonar user's password
chown -R sonartest: 123456 sonarqube-6.7.7 # assign permissions to the directory sonar
su sonartest # sonar user to switch to
/Opt/softs/sonarqube-6.7.7/bin/linux-x86-64 to the next directory,
Execution ./sonar.sh restart to start sonar
(. 1) ES given : Reference https://blog.csdn.net/zdyueguanyun/article/details/79447260
(2) where I also met a problem, ./sonar.sh restart when the incorrect report, said a yml file in the temp disable access to , and then I went into /opt/softs/sonarqube-6.7.7/temp, execute ls -all found to have root privileges to write files or, I suspect that might be generated by the implementation restart when I did not switch users, then just need to perform a "chown -R sonartest: 123456 sonarqube- 6.7.7" on it.
(3) there is a problem, restart when the error problem JVM failure , because there is no implementation of source / etc / profile so jdk environment variables to take effect, it is very simple when I switch users, and then perform a "source / etc / profile on it "
Here I checked the information, the solution has the following:
(3.1) Option 1: time to switch users using su command, / etc / profile will fail, should use su - username.
(3.2) Option 2:
(3.3) Option 3:
(https://blog.csdn.net/u011553945/article/details/101516559)
4. No success
In the browser enter http: // ip: 9000, if you see the following page shows a successful installation (default login ID is admin password is admin):
5. localization: After successful landing with admin admin, showing the operation according to the following:
Wait for the installation is completed, reboot:
Landing again, it becomes of the Chinese:
6.安装扫描器sonar-scanner
下载:https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/ (含简单的使用说明)
还在下载中。。。。
晚点补充
参考:
https://blog.csdn.net/zdyueguanyun/article/details/79447701