【Linux运维入门】安装sonar报错:JDBCError: Specified key was too long;

来源:互联网 发布:wenger淘宝 编辑:程序博客网 时间:2024/06/07 18:34

安装完SonarQ ube后,输入网址http://192.168.xx.xxx:9000 可以访问Sonar的页面。但是我却出现了一个问题:

错误一:

org.jruby.rack.RackInitializationException: An error has occurred, all later migrations canceled:ActiveRecord::JDBCError: Specified key was too long; max key length is 1000 bytes: CREATE UNIQUE INDEX `rules_repo_key` ON `rules` (`plugin_rule_key`, `plugin_name`)    from /usr/local/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'    from /usr/local/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401:in `up'    from /usr/local/sonar/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383:in `migrate'. ..ActiveRecord::JDBCError: Specified key was too long; max key length is 1000 bytes: CREATE UNIQUE INDEX `rules_repo_key` ON `rules` (`plugin_rule_key`, `plugin_name`)


错误原因:

Sonar在MySQL中对表建立索引时,key的长度超过1000 bytes了,由于MySQL默认使用MyISAM engine,而MyLSAM引擎会有key长度的限制,超过1000bytes就会报错,所以要将Mysql引擎修改为Innodb。


解决方式:

①. 查看是否有Innodb引擎

这里写图片描述

②. 查看是否支持动态载入动态链接库,yes表示支持。

这里写图片描述

③. 安装

这里写图片描述

查看是否安装成功。

这里写图片描述

⑤. 修改my.cnf配置文件:

default-storage-engine=INNODB# Uncomment the following if you are using InnoDB tablesinnodb_data_home_dir = /usr/local/varinnodb_data_file_path = ibdata1:10M:autoextendinnodb_log_group_home_dir = /usr/local/var# You can set .._buffer_pool_size up to 50 - 80 %# of RAM but beware of setting memory usage too highinnodb_buffer_pool_size = 256Minnodb_additional_mem_pool_size = 20M# Set .._log_file_size to 25 % of buffer pool sizeinnodb_log_file_size = 64Minnodb_log_buffer_size = 8Minnodb_flush_log_at_trx_commit = 1innodb_lock_wait_timeout = 50

然后删除刚才自动创建的数据库sonar,重启sonar。这次应该就没问题了。

但是,又报了个错:

错误二:

org.jruby.rack.RackInitializationException: An error has occurred, all later migrations canceled:ActiveRecord::JDBCError: Binary logging not possible. Message: Transaction level 'READ-UNCOMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT': INSERT INTO schema_migrations (version) VALUES ('710')    from /usr/local/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'    from /usr/local/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'    from /usr/local/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:490:in `migrate'    from org/jruby/RubyArray.java:1613:in `each'    from /usr/local/sonarqube/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:477:in `migrate'...    from file:/usr/local/sonarqube/lib/server/jruby-rack-1.1.13.2.jar!/jruby/rack/rails/environment2.rb:25:in `load_environment'    from file:/usr/local/sonarqube/lib/server/jruby-rack-1.1.13.2.jar!/jruby/rack/rails_booter.rb:79:in `load_environment'

错误原因:

innodb和binlog不兼容引起的,需要将binlog修改为混合模式。

解决方式:

修改my.cnf配置文件:

#binlog_format=mixed

把注释#号去掉,重启mysql,删除sonar数据库,重启sonar即可。


这次就没问题了,访问 http://192.168.xx.xxx:9000 ,就会出现sonar的界面。

1 0