sonar 服务器搭建 遇到各种问题

1. jvm 找不到   配置 jvm 配置环境变量

export JAVA_HOME=/usr/java/jdk1.8.0_51/
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin


2.数据库连接不上或者 database 找不到

java.lang.IllegalStateException: Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').

在mysql 中创建 sonar

然后jdbc 配置  jdbc:mysql://10.37.87.229:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance


连接数据库,会创建一系列表:

2017.11.15 10:35:36 INFO  web[][DbMigration] ==  InitialSchema: migrating ==================================================
2017.11.15 10:35:36 INFO  web[][DbMigration] -- create_table(:projects, {})
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0.0120s
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:36 INFO  web[][DbMigration] -- create_table(:snapshots, {})
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0.0120s
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:36 INFO  web[][DbMigration] -- create_table(:metrics, {})
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0.0110s
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:36 INFO  web[][DbMigration] -- create_table(:project_measures, {})
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0.0450s
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:36 INFO  web[][DbMigration] -- create_table(:rules, {})
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0.0140s
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:36 INFO  web[][DbMigration] -- create_table(:rules_parameters, {})
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:36 INFO  web[][DbMigration] -- create_table(:project_links, {})
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:36 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:36 INFO  web[][DbMigration] ==  InitialSchema: migrated (0.1180s) =========================================
2017.11.15 10:35:36 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  IndexDatabase: migrating ==================================================
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?("projects", "root_id", {:name=>"projects_root_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0060s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index("projects", "root_id", {:name=>"projects_root_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0110s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:project_measures, [:snapshot_id, :metric_id], {:name=>"measures_sid_metric"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0040s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:project_measures, [:snapshot_id, :metric_id], {:name=>"measures_sid_metric"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:rules_parameters, :rule_id, {:name=>"rules_parameters_rule_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0030s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:rules_parameters, :rule_id, {:name=>"rules_parameters_rule_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0080s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:snapshots, :project_id, {:name=>"snapshot_project_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0040s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:snapshots, :project_id, {:name=>"snapshot_project_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:snapshots, :parent_snapshot_id, {:name=>"snapshots_parent"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0040s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:snapshots, :parent_snapshot_id, {:name=>"snapshots_parent"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:snapshots, :root_snapshot_id, {:name=>"snapshots_root"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0040s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:snapshots, :root_snapshot_id, {:name=>"snapshots_root"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0090s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:snapshots, :qualifier, {:name=>"snapshots_qualifier"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0050s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:snapshots, :qualifier, {:name=>"snapshots_qualifier"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:metrics, :name, {:name=>"metrics_unique_name"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0030s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:metrics, :name, {:unique=>true, :name=>"metrics_unique_name"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0060s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  IndexDatabase: migrated (0.1080s) =========================================
2017.11.15 10:35:37 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateUsers: migrating ====================================================
2017.11.15 10:35:37 INFO  web[][DbMigration] -- create_table("users", {})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0140s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:users, :login, {:name=>"users_login"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0030s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:users, :login, {:name=>"users_login", :unique=>true})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0080s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateUsers: migrated (0.0270s) ===========================================
2017.11.15 10:35:37 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateAdministrator: migrating ============================================
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateAdministrator: migrated (0.0020s) ===================================
2017.11.15 10:35:37 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateRulesProfiles: migrating ============================================
2017.11.15 10:35:37 INFO  web[][DbMigration] -- create_table("rules_profiles", {})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0080s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- create_table("active_rules", {})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- create_table(:active_rule_parameters, {})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateRulesProfiles: migrated (0.0240s) ===================================
2017.11.15 10:35:37 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateSnapshotSources: migrating ==========================================
2017.11.15 10:35:37 INFO  web[][DbMigration] -- create_table(:snapshot_sources, {})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0160s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:snapshot_sources, :snapshot_id, {:name=>"snap_sources_snapshot_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0030s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:snapshot_sources, :snapshot_id, {:name=>"snap_sources_snapshot_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0060s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateSnapshotSources: migrated (0.0270s) =================================
2017.11.15 10:35:37 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateEventsTable: migrating ==============================================
2017.11.15 10:35:37 INFO  web[][DbMigration] -- create_table(:events, {})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0080s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:events, :resource_id, {:name=>"events_resource_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0030s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:events, :resource_id, {:name=>"events_resource_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0060s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:events, :snapshot_id, {:name=>"events_snapshot_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0020s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:events, :snapshot_id, {:name=>"events_snapshot_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0060s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateEventsTable: migrated (0.0290s) =====================================
2017.11.15 10:35:37 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateProperties: migrating ===============================================
2017.11.15 10:35:37 INFO  web[][DbMigration] -- create_table("properties", {})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:properties, :prop_key, {:name=>"properties_key"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0020s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:properties, :prop_key, {:name=>"properties_key", :length=>255})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0060s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateProperties: migrated (0.0170s) ======================================
2017.11.15 10:35:37 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateMeasureData: migrating ==============================================
2017.11.15 10:35:37 INFO  web[][DbMigration] -- create_table(:measure_data, {})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:measure_data, :measure_id, {:name=>"measure_data_measure_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0030s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:measure_data, :measure_id, {:name=>"measure_data_measure_id"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0080s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:measure_data, :snapshot_id, {:name=>"m_data_sid"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0030s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:measure_data, :snapshot_id, {:name=>"m_data_sid"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0240s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateMeasureData: migrated (0.0470s) =====================================
2017.11.15 10:35:37 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  AddProjectKeeIndex: migrating =============================================
2017.11.15 10:35:37 INFO  web[][DbMigration] -- index_exists?(:projects, :kee, {:name=>"projects_kee"})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0030s
2017.11.15 10:35:37 INFO  web[][DbMigration] -- add_index(:projects, :kee, {:name=>"projects_kee", :length=>255})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0070s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  AddProjectKeeIndex: migrated (0.0100s) ====================================
2017.11.15 10:35:37 INFO  web[][DbMigration] 
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateGroups: migrating ===================================================
2017.11.15 10:35:37 INFO  web[][DbMigration] -- create_table(:groups, {})
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0.0060s
2017.11.15 10:35:37 INFO  web[][DbMigration]    -> 0 rows
2017.11.15 10:35:37 INFO  web[][DbMigration] ==  CreateGroups: migrated (0.0100s) ==========================================
............
............

3.配置 LDAP 插件,缺少这个插件报错:

Caused by: org.sonar.api.utils.SonarException: Realm 'LDAP' not found. Please check the property 'sonar.security.realm' in conf/sonar.properties

[root@jenkispreapp246 plugins]# ll
total 51732
-rw-r--r-- 1 root root  3012713 Dec 19  2016 jacoco-0.7.7.201606060606.zip
-rw-r--r-- 1 root root      128 Dec 13  2016 README.txt
-rw-r--r-- 1 root root  6645997 Mar 22  2017 sonar-cfamily-plugin-4.6.0.7071.jar
-rw-r--r-- 1 root root 10883208 Dec 12  2016 sonar-csharp-plugin-5.5.1.522.jar
-rw-r--r-- 1 root root  9244889 Feb 19  2017 sonar-findbugs-plugin.jar
-rw-r--r-- 1 root root  5997408 Feb 19  2017 sonar-java-plugin-4.5.0.8398.jar
-rw-r--r-- 1 root root  2270669 May  4  2017 sonar-javascript-plugin-2.14.jar
-rw-r--r-- 1 root root    35621 Feb 21  2017 sonar-l10n-zh-plugin-1.14.jar
-rw-r--r-- 1 root root  4185611 Dec 19  2016 sonar-ldap-plugin-1.5.1.jar
-rw-r--r-- 1 root root    14188 Dec 19  2016 sonar-motion-chart-plugin-1.7.jar
-rw-r--r-- 1 root root  3233128 Dec  7  2016 sonar-scm-git-plugin-1.2.jar
-rw-r--r-- 1 root root  6564536 Dec 19  2016 sonar-scm-svn-plugin-1.3.jar
-rw-r--r-- 1 root root   854081 Dec 19  2016 sonar-web-plugin-2.4.jar
[root@jenkispreapp246 plugins]# sz   ..

配置好插件重启。

重启指令: 

shutdown -r now
sh /opt/CI/sonarqube-6.2/bin/linux-x86-64/sonar.sh start


4.sonar 系统(服务器)自带自己的用户,admin/admin   自己也可以 在设置里面修改


5.sonar 对应创建的数据表

active_rule_parameters,    active_rules, authors,    ce_activity, ce_queue,   ce_scanner_context,   ce_task_input,   duplications_index, events,   file_sources,   group_roles, groups, groups_users, internal_properties,   issue_changes, issues, loaded_templates, manual_measures, metrics,   notifications, organizations,   perm_templates_groups, perm_templates_users, perm_tpl_characteristics, permission_templates, project_links, project_measures, project_qprofiles, projects, properties, qprofile_changes, quality_gate_conditions, quality_gates,   resource_index, r  ule_repositories,  rules,  rules_parameters, r ules_profiles,   schema_migrations,   snapshots,   user_roles, user_tokens,   users,   webhook_deliveries




你可能感兴趣的:(sonar)