前言
    一款不错的代码质量管理工具Sonar
前期准备
    软件下载
    硬件环境(在官方参考文档有提出硬件规格,如下只是测试环境)
            磁盘 ->16G
            内存 ->2G
            CPU -> 2core
    软件环境
            OS -> Red Hat Enterprise 6.5
            DB -> Mysql 5.7
            Sonar -> SonarQube 6.7.1 (LTS *)
            IP -> 192.168.1.59
            Host -> t-xi-sonar01
系统初始化
        关闭selinux和防火墙
           [root@t-xi-sonar01 ~]# vi /etc/selinux/config
               SELINUX=disabled
           [root@t-xi-sonar01 ~]# chkconfig  iptables off&&chkconfig  ip6tables off&&service iptables stop&&service ip6tables stop
      [root@t-xi-sonar01 ~]# vi /etc/hosts

            192.168.1.59 t-xi-sonar01
        配置Yum源,我这里配置了web站点,所以指定了http地址.
          [root@t-xi-sonar01 ~]# cat /etc/yum.repos.d/rhel-source.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
enabled=1
gpgcheck=0
 
  也可以使用ios镜像进行配置yum源
 [root@t-xi-orc01 ~]# mount -o loop /u01/rhel-server-6.5-x86_64-dvd.iso /u01/http/redhat6.5
 [root@t-xi-orc01 ~]# cat /etc/yum.repos.d/rhel-source.repo
 [Server]
 name=Red Hat Enterprise Linux $releasever - $basearch - Server
 baseurl=file:///u01/http/redhat6.5/Server
 enabled=1
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
        
        系统内核优化(参考文档中有)

 [root@t-xi-sonar01 ~]# vi /etc/sysctl.conf
#add sonar
vm.max_map_count =
fs.file-max = [root@t-xi-sonar01 ~]# vi /etc/security/limits.conf
#add sonar
sonarqube - nofile
sonarqube - nproc sysctl -w vm.max_map_count=
sysctl -w fs.file-max=
ulimit -n
ulimit -u

安装Mysql数据库

      首先移除原有mysql-libs-5.1.71-1.el6.x86_64包,但它依赖postfix。
      [root@t-xi-sonar01 ~]# yum remove postfix
      [root@t-xi-sonar01 ~]# rpm -e mysql-libs-5.1.71-1.el6.x86_64
      安装下载的Mysql 5.7
      [root@t-xi-sonar01 ~]#
        rpm -ivh mysql-community-client-5.7.20-1.el6.x86_64.rpm
        rpm -ivh mysql-community-common-5.7.20-1.el6.x86_64.rpm
        rpm -ivh mysql-community-devel-5.7.20-1.el6.x86_64.rpm
        rpm -ivh mysql-community-embedded-5.7.20-1.el6.x86_64.rpm
        rpm -ivh mysql-community-embedded-devel-5.7.20-1.el6.x86_64.rpm
        rpm -ivh mysql-community-libs-5.7.20-1.el6.x86_64.rpm
        rpm -ivh mysql-community-libs-compat-5.7.20-1.el6.x86_64.rpm
        rpm -ivh mysql-community-server-5.7.20-1.el6.x86_64.rpm

  注意将原来移除的包重新安装
        yum install postfix  crontabs
            优化Mysql数据库参数     
[root@t-xi-sonar01 ~]# vi /etc/my.cnf
query_cache_size=8M
innodb_buffer_pool_size=1152M
innodb_log_file_size=256M
innodb_log_buffer_size=4M
innodb_flush_log_at_trx_commit=
innodb_thread_concurrency=
innodb_flush_method=O_DIRECT
transaction-isolation=READ-COMMITTED
thread_cache_size=
slow_query_log=on
slow-query-log-file=mysqld-slow.log
long_query_time=
explicit_defaults_for_timestamp=true
skip-character-set-client-handshake
collation-server=utf8_unicode_ci
character-set-server=utf8

  启动数据库,此时数据库会生成临时密码

            [root@t-xi-sonar01 ~]# service mysqld start
           启动时要随时关注mysql数据库产生的日志记录
            [root@t-xi-sonar01 ~]# tail -f  /var/log/mysqld.log
           查看临时密码
            [root@t-xi-sonar01 ~]#grep 'temporary password' /var/log/mysqld.log
                2017-12-26T10:37:57.842981Z 1 [Note] A temporary password is generated for root@localhost: cSj&aPfkS60w
            登陆并且更新密码
            [root@t-xi-sonar01 ~]#mysql -uroot -p
            mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY '******';
            mysql>FLUSH PRIVILEGES;
            将mysql数据库设定为自启动
            [root@t-xi-sonar01 ~]# chkconfig mysqld on
            
    创建Sonar账户和数据库
            [root@t-xi-sonar01 ~]#useradd sonar
            [root@t-xi-sonar01 ~]#passwrd sonar
 
            [root@t-xi-sonar01 ~]#mysql -uroot -p
            mysql>create user 'sonar'@'localhost' identified by 'sonar';
            mysql>CREATE DATABASE sonar
                          DEFAULT CHARACTER SET utf8
                          DEFAULT COLLATE utf8_general_ci;
            mysql>GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'localhost';
            mysql>FLUSH PRIVILEGES;
 
    安装Sonar软件
            [root@t-xi-sonar01 ~]# unzip sonarqube-6.7.1.zip
            [root@t-xi-sonar01 ~]# mv sonarqube-6.7.1 /etc/sonarqube
            [root@t-xi-sonar01 ~]# chown -R sonar.sonar /etc/sonarqube
                注意:sonarqube后面启动 ./sonar.sh start时不能使用root账户,es.log报错信息
                 2017.12.27 13:59:30 ERROR es[][o.e.b.Bootstrap] Exception java.lang.RuntimeException: can not run elasticsearch as root
  切换到Sonar账户
            [sonar@t-xi-sonar01 sonarqube]$
            [root@t-xi-sonar01 sonarqube]# su - sonar
            [sonar@t-xi-sonar01 ~]$ cd /etc/sonarqube/
        查看/etc/sonarqube目录树(主要的三个,可以查看参考文档)

bin ->软件运行目录
conf -> 软件配置目录
COPYING
data
elasticsearch
extensions
lib
logs ->软件运行日志目录
temp
web

配置软件参数

                    [sonar@t-xi-sonar01 sonarqube]$ cat conf/sonar.properties|grep -v '^#'|grep -v '^$'|grep -v '=$'
      

sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
                            注意Sonar Web访问默认地址为9000,账户admin/admin
 
                     启动Sonar软件 
                               [sonar@t-xi-sonar01 sonarqube]$ bin/linux-x86-64/sonar.sh start
                               注意查看logs/es.log 和logs/sonar.log两个日志文件
         [sonar@t-xi-sonar01 sonarqube]$ less logs/es.log
                         [sonar@t-xi-sonar01 sonarqube]$ less logs/sonar.log
            访问Sonar
                http://192.168.1.59:9000
    

    

    

                
  前期配置Sonar完成,后续完善中文字符和Jekins的整合
 
参考网址:
 
 
 
 
 
 
            
 
 
 
        

最新文章

  1. table 标签
  2. overflow:hidden清楚浮动的影响
  3. linux 学习3 第四讲 文件常用命令
  4. mac下apache配置,解决It is not safe to rely on the system's timezone settings.
  5. EasyUI datagrid优化
  6. js Array对象
  7. python day1 常用模块
  8. Nginx和PHP-FPM的启动、重启、停止脚本分享(转)
  9. JZ2440开发笔记(6)——存储控制器
  10. mirantis fuel
  11. WCF-IIS-PDA
  12. Oracle sql语句创建表空间、数据库、用户及授权
  13. 操作系统,银行家算法模拟实现(Windows 环境 C++)
  14. HttpClient入门一
  15. Docker 多主机方案
  16. Centos7.4别名设置提高工作效率
  17. iOS objc_msgSend 报错解决方案
  18. iOS开发-通讯录有界面
  19. js replace 全局替换
  20. BZOJ.3498.[PA2009]Cakes(三元环 枚举)

热门文章

  1. 避免console错误,console兼容
  2. ubuntu GITLAB完全导入SVN(提交历史,用户)项目
  3. Android 解决Glide 加载图片缓慢(第一次加载不出来图片)的Bug
  4. linux搭建nginx图片服务器
  5. Oracle自定义行转列函数
  6. 3元购买微信小程序解决方案一个月
  7. myeclipse 阿里巴巴java开发规范
  8. oracle 比较两个用户表结构的区别。
  9. 第一次团队Scrum
  10. Windos下Android(ADT Bundle)配置NDK的两种方法------ADT、Cygwin、NDK配置汇总(转)